Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uritemplate-js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
uritemplate-js
Commits
104949aa
Commit
104949aa
authored
Jun 30, 2012
by
fxa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue #1 wrong behaviour with ':'
parent
b03daea2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
5 deletions
+36
-5
README.md
README.md
+7
-0
own-testcases.json
own-testcases.json
+12
-0
package.json
package.json
+1
-1
src/uritemplate.js
src/uritemplate.js
+14
-4
test.js
test.js
+2
-0
No files found.
README.md
View file @
104949aa
...
...
@@ -26,6 +26,13 @@ and then:
template.expand({query: {first: 1, second: 2}});
--> "?first=1&second=2"
If you want to clone the git project, be aware of the submodule uritemplate-test.
So you have to to:
git https://github.com/fxa/uritemplate-js.git
git submodule init
git submodule update
Tests
-----
...
...
own-testcases.json
0 → 100644
View file @
104949aa
{
"Jira bug #1"
:
{
"comment"
:
"tests, whether the '://' can be passed"
,
"level"
:
1
,
"variables"
:
{
"q"
:
"val"
},
"testcases"
:
[
[
"http://localhost:8080/api/search{?q}"
,
"http://localhost:8080/api/search?q=val"
]
]
}
}
package.json
View file @
104949aa
...
...
@@ -23,5 +23,5 @@
"uritemplate-test/spec-examples-by-sections.json"
,
"uritemplate-test/spec-examples.json"
],
"version"
:
"0.1.
2
"
"version"
:
"0.1.
3
"
}
\ No newline at end of file
src/uritemplate.js
View file @
104949aa
...
...
@@ -32,6 +32,16 @@
}
return
currentValue
;
}
function
arrayAll
(
array
,
predicate
)
{
var
index
;
for
(
index
=
0
;
index
<
array
.
length
;
index
+=
1
)
{
if
(
!
predicate
(
array
[
index
],
index
,
array
))
{
return
false
;
}
}
return
true
;
}
function
reduce
(
arrayOrObject
,
callback
,
initialValue
)
{
return
isArray
(
arrayOrObject
)
?
arrayReduce
(
arrayOrObject
,
callback
,
initialValue
)
:
objectReduce
(
arrayOrObject
,
callback
,
initialValue
);
...
...
@@ -473,10 +483,10 @@
literalStart
=
null
;
braceOpenIndex
=
index
;
}
// TODO
check for allowed chars. This if-statement is just to pass the uritemplate-test
if
(
chr
===
'
:
'
&&
uriTemplateText
.
substring
(
literalStart
,
index
).
indexOf
(
'
/
'
)
>=
0
)
{
throw
new
Error
(
'
":" not allowed after a "/" in a regular uri
'
);
}
// TODO
if (chr === ';')
// In a regular URI a colon is only allowed as separator after a uri scheme (e.g. 'http:') and between host and port
// (e.g. 'example.com:443'). So the only slash allowed in front of a colon is the '//' after the scheme separator
// throw new Error('":" not allowed after a "/" in a regular uri');
continue
;
}
...
...
test.js
View file @
104949aa
...
...
@@ -81,6 +81,8 @@
runTestFile
(
'
uritemplate-test/spec-examples.json
'
);
runTestFile
(
'
uritemplate-test/extended-tests.json
'
);
runTestFile
(
'
uritemplate-test/negative-tests.json
'
);
runTestFile
(
'
own-testcases.json
'
);
console
.
log
(
'
passed all
'
+
numTestsPassed
+
'
tests!
'
);
}());
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment