Commit 104949aa authored by fxa's avatar fxa

fixed issue #1 wrong behaviour with ':'

parent b03daea2
......@@ -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
-----
......
{
"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"]
]
}
}
......@@ -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
......@@ -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;
}
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment