Commit aa5b2ecf authored by fxa's avatar fxa

introduced UriTemplateError as exception, so the interface changed from string...

introduced UriTemplateError as exception, so the interface changed from string to UriTemplateError (as the rfc suggested)
parent f88149e5
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
SRC_HOME = 'src', SRC_HOME = 'src',
SRC_FILES = [ SRC_FILES = [
// cannot use the fileList, because the order matters // cannot use the fileList, because the order matters
path.join(SRC_HOME, 'UriTemplateError.js'),
path.join(SRC_HOME, 'objectHelper.js'), path.join(SRC_HOME, 'objectHelper.js'),
path.join(SRC_HOME, 'charHelper.js'), path.join(SRC_HOME, 'charHelper.js'),
path.join(SRC_HOME, 'pctEncoder.js'), path.join(SRC_HOME, 'pctEncoder.js'),
......
...@@ -62,6 +62,7 @@ MIT License, see http://mit-license.org/ ...@@ -62,6 +62,7 @@ MIT License, see http://mit-license.org/
Release Notes Release Notes
------------- -------------
* 0.3.0 introduced UriTemplateError as exception, so the interface changed from string to UriTemplateError (as the rfc suggested)
* 0.2.4 fixed double encoding according [RubenVerborgh] and some Prefix modifiers bugs * 0.2.4 fixed double encoding according [RubenVerborgh] and some Prefix modifiers bugs
* 0.2.3 fixed bug with empty objects ('{?empty}' with '{empty:{}}' shall expand to '?empty=') * 0.2.3 fixed bug with empty objects ('{?empty}' with '{empty:{}}' shall expand to '?empty=')
* 0.2.2 fixed pct encoding bug with multibyte utf8 chars * 0.2.2 fixed pct encoding bug with multibyte utf8 chars
......
...@@ -11,8 +11,8 @@ module.exports = (function () { ...@@ -11,8 +11,8 @@ module.exports = (function () {
bitwise: true, // bitwise is forbidden bitwise: true, // bitwise is forbidden
curly: true, // must put oneliners in curly braces curly: true, // must put oneliners in curly braces
eqeqeq: true, // must use === eqeqeq: true, // must use ===
forin: true, forin: true, // for in must use hasOwnProperty()
immed: true, // wrap immediately called functions immed: true, // immediately called functions must be wrapped in ()
newcap: true, // CAP constructors newcap: true, // CAP constructors
noarg: true, // arguments.caller is evil noarg: true, // arguments.caller is evil
noempty: true, // empty blocks are forbidden noempty: true, // empty blocks are forbidden
...@@ -21,9 +21,7 @@ module.exports = (function () { ...@@ -21,9 +21,7 @@ module.exports = (function () {
strict: true, // must use "use strict" strict: true, // must use "use strict"
undef: true, // forbids use of undefined variables undef: true, // forbids use of undefined variables
unused: true, // forbids unused variables unused: true, // forbids unused variables
maxcomplexity: 20 // much too high. should be max. 10
maxcomplexity: 19 // much too high. should be max. 10
}, },
JSHINT_GLOBALS = { JSHINT_GLOBALS = {
"module": true "module": true
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
["{a,.b}", false] ["{a,.b}", false]
] ]
}, },
"Prefix modifiers": { "Prefix modifiers and exploded": {
"level": 4, "level": 4,
"variables": { "variables": {
"text": "I like octal numbers", "text": "I like octal numbers",
...@@ -40,8 +40,34 @@ ...@@ -40,8 +40,34 @@
["{emptyObject:1}", ""], ["{emptyObject:1}", ""],
["{filledObject:1}", false], ["{filledObject:1}", false],
["{emptyArr:1}", ""], ["{emptyArr:1}", ""],
["{filledArr:1}", false] ["{filledArr:1}", false],
["{text:1:1}", false],
["{?*}", false],
["{?:1}", false],
["{?a,:1}", false],
["{*}", false],
["{text**}", false],
["{text:1*}", false],
["{text*:1}", false]
] ]
},
"Prefix modifiers, next generation": {
"level": 4,
"variables": {
"bool": false,
"int": 123,
"float": 123.4,
"exp": 1.2e+3,
"null": null
},
"testcases": [
["{bool:1}", "f"],
["{int:1}", "1"],
["{float:1}", "1"],
["{exp:1}", "1"],
["{null:1}", ""],
["{null:1}", ""]
]
} }
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"uritemplate-test/spec-examples-by-sections.json", "uritemplate-test/spec-examples-by-sections.json",
"uritemplate-test/spec-examples.json" "uritemplate-test/spec-examples.json"
], ],
"version": "0.2.4", "version": "0.3.0",
"readmeFilename": "README.md", "readmeFilename": "README.md",
"gitHead": "901b85201a821427dfb4591b56aea3a70d45c67c", "gitHead": "901b85201a821427dfb4591b56aea3a70d45c67c",
"devDependencies": { "devDependencies": {
......
/*jshint unused:false */ /*jshint unused:false */
/*global pctEncoder, rfcCharHelper*/ /*global pctEncoder, rfcCharHelper, encodingHelper*/
var LiteralExpression = (function () { var LiteralExpression = (function () {
"use strict"; "use strict";
function LiteralExpression (literal) { function LiteralExpression (literal) {
this.literal = LiteralExpression.encodeLiteral(literal); this.literal = encodingHelper.encodeLiteral(literal);
} }
LiteralExpression.encodeLiteral = function (literal) {
var
result = '',
index,
chr = '';
for (index = 0; index < literal.length; index += chr.length) {
chr = pctEncoder.pctCharAt(literal, index);
if (chr.length > 1) {
result += chr;
}
else {
result += rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr);
}
// chr = literal.charAt(index);
// result += rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr);
}
return result;
};
LiteralExpression.prototype.expand = function () { LiteralExpression.prototype.expand = function () {
return this.literal; return this.literal;
}; };
......
/*jshint unused:false */
var UriTemplateError = (function () {
"use strict";
function UriTemplateError (options) {
this.options = options;
}
UriTemplateError.prototype.toString = function () {
if (JSON && JSON.stringify) {
return JSON.stringify(this.options);
}
else {
return this.options;
}
};
return UriTemplateError;
}());
/*jshint unused:false */ /*jshint unused:false */
/*global parse, objectHelper*/ /*global parse, objectHelper, UriTemplateError*/
var UriTemplate = (function () { var UriTemplate = (function () {
"use strict"; "use strict";
function UriTemplate (templateText, expressions) { function UriTemplate (templateText, expressions) {
...@@ -24,5 +24,6 @@ var UriTemplate = (function () { ...@@ -24,5 +24,6 @@ var UriTemplate = (function () {
}; };
UriTemplate.parse = parse; UriTemplate.parse = parse;
UriTemplate.UriTemplateError = UriTemplateError;
return UriTemplate; return UriTemplate;
}()); }());
/*jshint unused:false */ /*jshint unused:false */
/*global pctEncoder, rfcCharHelper, isDefined, LiteralExpression, objectHelper*/ /*global pctEncoder, rfcCharHelper, isDefined, objectHelper, encodingHelper*/
var VariableExpression = (function () { var VariableExpression = (function () {
"use strict"; "use strict";
// helper function if JSON is not available // helper function if JSON is not available
...@@ -46,7 +46,7 @@ var VariableExpression = (function () { ...@@ -46,7 +46,7 @@ var VariableExpression = (function () {
if (result.length > 0) { if (result.length > 0) {
result += operator.separator; result += operator.separator;
} }
result += (valueIsArr) ? LiteralExpression.encodeLiteral(varspec.varname) : operator.encode(currentKey); result += (valueIsArr) ? encodingHelper.encodeLiteral(varspec.varname) : operator.encode(currentKey);
result += '=' + operator.encode(currentValue); result += '=' + operator.encode(currentValue);
} }
return result; return result;
...@@ -83,7 +83,7 @@ var VariableExpression = (function () { ...@@ -83,7 +83,7 @@ var VariableExpression = (function () {
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
value = value.toString(); value = value.toString();
if (operator.named) { if (operator.named) {
result += LiteralExpression.encodeLiteral(varspec.varname); result += encodingHelper.encodeLiteral(varspec.varname);
if (value === '') { if (value === '') {
result += operator.ifEmpty; result += operator.ifEmpty;
continue; continue;
...@@ -101,7 +101,7 @@ var VariableExpression = (function () { ...@@ -101,7 +101,7 @@ var VariableExpression = (function () {
} }
else if (!varspec.exploded) { else if (!varspec.exploded) {
if (operator.named) { if (operator.named) {
result += LiteralExpression.encodeLiteral(varspec.varname); result += encodingHelper.encodeLiteral(varspec.varname);
if (!isDefined(value)) { if (!isDefined(value)) {
result += operator.ifEmpty; result += operator.ifEmpty;
continue; continue;
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
var charHelper = (function () { var charHelper = (function () {
"use strict"; "use strict";
function isAlpha(chr) { function isAlpha (chr) {
return (chr >= 'a' && chr <= 'z') || ((chr >= 'A' && chr <= 'Z')); return (chr >= 'a' && chr <= 'z') || ((chr >= 'A' && chr <= 'Z'));
} }
function isDigit(chr) { function isDigit (chr) {
return chr >= '0' && chr <= '9'; return chr >= '0' && chr <= '9';
} }
function isHexDigit(chr) { function isHexDigit (chr) {
return isDigit(chr) || (chr >= 'a' && chr <= 'f') || (chr >= 'A' && chr <= 'F'); return isDigit(chr) || (chr >= 'a' && chr <= 'f') || (chr >= 'A' && chr <= 'F');
} }
......
...@@ -25,9 +25,27 @@ var encodingHelper = (function () { ...@@ -25,9 +25,27 @@ var encodingHelper = (function () {
return encode(text, true); return encode(text, true);
} }
function encodeLiteral (literal) {
var
result = '',
index,
chr = '';
for (index = 0; index < literal.length; index += chr.length) {
chr = pctEncoder.pctCharAt(literal, index);
if (chr.length > 1) {
result += chr;
}
else {
result += rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr);
}
}
return result;
}
return { return {
encode: encode, encode: encode,
encodePassReserved: encodePassReserved encodePassReserved: encodePassReserved,
encodeLiteral: encodeLiteral
}; };
}()); }());
...@@ -8,7 +8,7 @@ var operators = (function () { ...@@ -8,7 +8,7 @@ var operators = (function () {
var var
bySymbol = {}; bySymbol = {};
function create(symbol) { function create (symbol) {
bySymbol[symbol] = { bySymbol[symbol] = {
symbol: symbol, symbol: symbol,
separator: (symbol === '?') ? '&' : (symbol === '' || symbol === '+' || symbol === '#') ? ',' : symbol, separator: (symbol === '?') ? '&' : (symbol === '' || symbol === '+' || symbol === '#') ? ',' : symbol,
...@@ -30,13 +30,15 @@ var operators = (function () { ...@@ -30,13 +30,15 @@ var operators = (function () {
create(';'); create(';');
create('?'); create('?');
create('&'); create('&');
return {valueOf: function (chr) { return {
if (bySymbol[chr]) { valueOf: function (chr) {
return bySymbol[chr]; if (bySymbol[chr]) {
} return bySymbol[chr];
if ("=,!@|".indexOf(chr) >= 0) { }
throw new Error('Illegal use of reserved operator "' + chr + '"'); if ("=,!@|".indexOf(chr) >= 0) {
return null;
}
return bySymbol[''];
} }
return bySymbol['']; };
}};
}()); }());
/*jshint unused:false */ /*jshint unused:false */
/*global pctEncoder, operators, charHelper, rfcCharHelper, LiteralExpression, UriTemplate, VariableExpression*/ /*global pctEncoder, operators, charHelper, rfcCharHelper, LiteralExpression, UriTemplate, VariableExpression, UriTemplateError*/
var parse = (function () { var parse = (function () {
"use strict"; "use strict";
function parseExpression (outerText) {
function parseExpression (expressionText) {
var var
text,
operator, operator,
varspecs = [], varspecs = [],
varspec = null, varspec = null,
...@@ -14,34 +14,42 @@ var parse = (function () { ...@@ -14,34 +14,42 @@ var parse = (function () {
chr = ''; chr = '';
function closeVarname () { function closeVarname () {
varspec = {varname: text.substring(varnameStart, index), exploded: false, maxLength: null}; var varname = expressionText.substring(varnameStart, index);
if (varname.length === 0) {
throw new UriTemplateError({expressionText: expressionText, message: "a varname must be specified", position: index});
}
varspec = {varname: varname, exploded: false, maxLength: null};
varnameStart = null; varnameStart = null;
} }
function closeMaxLength () { function closeMaxLength () {
if (maxLengthStart === index) { if (maxLengthStart === index) {
throw new Error("after a ':' you have to specify the length. position = " + index); throw new UriTemplateError({expressionText: expressionText, message: "after a ':' you have to specify the length", position: index});
} }
varspec.maxLength = parseInt(text.substring(maxLengthStart, index), 10); varspec.maxLength = parseInt(expressionText.substring(maxLengthStart, index), 10);
maxLengthStart = null; maxLengthStart = null;
} }
// remove outer braces operator = (function (operatorText) {
text = outerText.substr(1, outerText.length - 2); var op = operators.valueOf(operatorText);
if (op === null) {
throw new UriTemplateError({expressionText: expressionText, message: "illegal use of reserved operator", position: index, operator: operatorText});
}
return op;
}(expressionText.charAt(0)));
index = operator.symbol.length;
// determine operator
operator = operators.valueOf(text.charAt(0));
index = (operator.symbol === '') ? 0 : 1;
varnameStart = index; varnameStart = index;
for (; index < text.length; index += chr.length) { for (; index < expressionText.length; index += chr.length) {
chr = pctEncoder.pctCharAt(text, index); chr = pctEncoder.pctCharAt(expressionText, index);
if (varnameStart !== null) { if (varnameStart !== null) {
// the spec says: varname = varchar *( ["."] varchar ) // the spec says: varname = varchar *( ["."] varchar )
// so a dot is allowed except for the first char // so a dot is allowed except for the first char
if (chr === '.') { if (chr === '.') {
if (varnameStart === index) { if (varnameStart === index) {
throw new Error('a varname MUST NOT start with a dot -- see position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "a varname MUST NOT start with a dot", position: index});
} }
continue; continue;
} }
...@@ -52,11 +60,11 @@ var parse = (function () { ...@@ -52,11 +60,11 @@ var parse = (function () {
} }
if (maxLengthStart !== null) { if (maxLengthStart !== null) {
if (index === maxLengthStart && chr === '0') { if (index === maxLengthStart && chr === '0') {
throw new Error('A :prefix must not start with digit 0 -- see position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "A :prefix must not start with digit 0", position: index});
} }
if (charHelper.isDigit(chr)) { if (charHelper.isDigit(chr)) {
if (index - maxLengthStart >= 4) { if (index - maxLengthStart >= 4) {
throw new Error('A :prefix must max 4 digits -- see position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "A :prefix must have max 4 digits", position: index});
} }
continue; continue;
} }
...@@ -64,20 +72,23 @@ var parse = (function () { ...@@ -64,20 +72,23 @@ var parse = (function () {
} }
if (chr === ':') { if (chr === ':') {
if (varspec.maxLength !== null) { if (varspec.maxLength !== null) {
throw new Error('only one :maxLength is allowed per varspec at position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "only one :maxLength is allowed per varspec", position: index});
}
if (varspec.exploded) {
throw new UriTemplateError({expressionText: expressionText, message: "an exploeded varspec MUST NOT be varspeced", position: index});
} }
maxLengthStart = index + 1; maxLengthStart = index + 1;
continue; continue;
} }
if (chr === '*') { if (chr === '*') {
if (varspec === null) { if (varspec === null) {
throw new Error('explode exploded at position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "exploded without varspec", position: index});
} }
if (varspec.exploded) { if (varspec.exploded) {
throw new Error('explode exploded twice at position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "exploded twice", position: index});
} }
if (varspec.maxLength) { if (varspec.maxLength) {
throw new Error('an explode (*) MUST NOT follow to a prefix, see position ' + index); throw new UriTemplateError({expressionText: expressionText, message: "an explode (*) MUST NOT follow to a prefix", position: index});
} }
varspec.exploded = true; varspec.exploded = true;
continue; continue;
...@@ -89,7 +100,7 @@ var parse = (function () { ...@@ -89,7 +100,7 @@ var parse = (function () {
varnameStart = index + 1; varnameStart = index + 1;
continue; continue;
} }
throw new Error("illegal character '" + chr + "' at position " + index + ' of "' + text + '"'); throw new UriTemplateError({expressionText: expressionText, message: "illegal character", character: chr, position: index});
} // for chr } // for chr
if (varnameStart !== null) { if (varnameStart !== null) {
closeVarname(); closeVarname();
...@@ -98,10 +109,10 @@ var parse = (function () { ...@@ -98,10 +109,10 @@ var parse = (function () {
closeMaxLength(); closeMaxLength();
} }
varspecs.push(varspec); varspecs.push(varspec);
return new VariableExpression(outerText, operator, varspecs); return new VariableExpression(expressionText, operator, varspecs);
} }
function parseTemplate (uriTemplateText) { function parse (uriTemplateText) {
// assert filled string // assert filled string
var var
index, index,
...@@ -113,7 +124,7 @@ var parse = (function () { ...@@ -113,7 +124,7 @@ var parse = (function () {
chr = uriTemplateText.charAt(index); chr = uriTemplateText.charAt(index);
if (literalStart !== null) { if (literalStart !== null) {
if (chr === '}') { if (chr === '}') {
throw new Error('brace was closed in position ' + index + " but never opened"); throw new UriTemplateError({templateText: uriTemplateText, message: "unopened brace closed", position: index});
} }
if (chr === '{') { if (chr === '{') {
if (literalStart < index) { if (literalStart < index) {
...@@ -128,13 +139,21 @@ var parse = (function () { ...@@ -128,13 +139,21 @@ var parse = (function () {
if (braceOpenIndex !== null) { if (braceOpenIndex !== null) {
// here just { is forbidden // here just { is forbidden
if (chr === '{') { if (chr === '{') {
throw new Error('brace was opened in position ' + braceOpenIndex + " and cannot be reopened in position " + index); throw new UriTemplateError({templateText: uriTemplateText, message: "brace already opened", position: index});
} }
if (chr === '}') { if (chr === '}') {
if (braceOpenIndex + 1 === index) { if (braceOpenIndex + 1 === index) {
throw new Error("empty braces on position " + braceOpenIndex); throw new UriTemplateError({templateText: uriTemplateText, message: "empty braces", position: braceOpenIndex});
}
try {
expressions.push(parseExpression(uriTemplateText.substring(braceOpenIndex + 1, index)));
}
catch (error) {
if (error.prototype === UriTemplateError.prototype) {
throw new UriTemplateError({templateText: uriTemplateText, message: error.options.message, position: braceOpenIndex + error.options.position, details: error.options});
}
throw error;
} }
expressions.push(parseExpression(uriTemplateText.substring(braceOpenIndex, index + 1)));
braceOpenIndex = null; braceOpenIndex = null;
literalStart = index + 1; literalStart = index + 1;
} }
...@@ -143,7 +162,7 @@ var parse = (function () { ...@@ -143,7 +162,7 @@ var parse = (function () {
throw new Error('reached unreachable code'); throw new Error('reached unreachable code');
} }
if (braceOpenIndex !== null) { if (braceOpenIndex !== null) {
throw new Error("brace was opened on position " + braceOpenIndex + ", but never closed"); throw new UriTemplateError({templateText: uriTemplateText, message: "unclosed brace", position: braceOpenIndex});
} }
if (literalStart < uriTemplateText.length) { if (literalStart < uriTemplateText.length) {
expressions.push(new LiteralExpression(uriTemplateText.substr(literalStart))); expressions.push(new LiteralExpression(uriTemplateText.substr(literalStart)));
...@@ -151,5 +170,5 @@ var parse = (function () { ...@@ -151,5 +170,5 @@ var parse = (function () {
return new UriTemplate(uriTemplateText, expressions); return new UriTemplate(uriTemplateText, expressions);
} }
return parseTemplate; return parse;
}()); }());
...@@ -9,7 +9,7 @@ module.exports = (function () { ...@@ -9,7 +9,7 @@ module.exports = (function () {
var NOISY = false; var NOISY = false;
function log (text) { function log (text) {
if (NOISY) { if (NOISY) {
console.log(text); console.log.call(null, arguments);
} }
} }
...@@ -32,19 +32,20 @@ module.exports = (function () { ...@@ -32,19 +32,20 @@ module.exports = (function () {
uriTemplate = UriTemplate.parse(template); uriTemplate = UriTemplate.parse(template);
} }
catch (error) { catch (error) {
if (expected === false) { if (expected === false && error.constructor.prototype === UriTemplate.UriTemplateError.prototype) {
log('ok. expected error found'); log('ok. expected error found', error);
return; return;
} }
console.log('error', error); console.log('error', error);
test.fail('chapter ' + chapterName + ', template ' + template + ' threw error, when parsing: ' + error); console.log('error.constructor.prototype', error.constructor.prototype);
test.fail('chapter ' + chapterName + ', template ' + template + ' threw error: ' + error);
return; return;
} }
test.ok(!!uriTemplate, 'uri template could not be parsed'); test.ok(!!uriTemplate, 'uri template could not be parsed');
try { try {
actual = uriTemplate.expand(variables); actual = uriTemplate.expand(variables);
if (expected === false) { if (expected === false) {
test.fail('chapter ' + chapterName + ', template ' + template + ' expected to fail, but returned \'' + actual + '\'!'); test.fail('chapter ' + chapterName + ', template ' + template + ' expected to fail, but returned \'' + actual + '\'');
return; return;
} }
} }
...@@ -53,7 +54,7 @@ module.exports = (function () { ...@@ -53,7 +54,7 @@ module.exports = (function () {
return; return;
} }
console.log('error', error); console.log('error', error);
test.fail('chapter ' + chapterName + ', template ' + template + ' threw error, when expanding: ' + JSON.stringify(error, null, 4)); test.fail('chapter ' + chapterName + ', template "' + template + '" threw error, when expanding: ' + JSON.stringify(error, null, 4));
return; return;
} }
if (expected.constructor === Array) { if (expected.constructor === Array) {
......
module.exports = (function () {
"use strict";
var
sandbox = require('nodeunit').utils.sandbox,
context = {};
sandbox('src/charHelper.js', context);
sandbox('src/pctEncoder.js', context);
sandbox('src/rfcCharHelper.js', context);
sandbox('src/encodingHelper.js', context);
var encodingHelper = context.encodingHelper;
return {
'encodeLiteral works as expected': function (test) {
test.equal(typeof encodingHelper.encodeLiteral, 'function');
test.equal(encodingHelper.encodeLiteral('a b'), 'a%20b');
test.equal(encodingHelper.encodeLiteral('a%20b'), 'a%20b');
test.done();
}
};
}());
\ No newline at end of file
...@@ -12,10 +12,8 @@ module.exports = (function () { ...@@ -12,10 +12,8 @@ module.exports = (function () {
var LiteralExpression = context.LiteralExpression; var LiteralExpression = context.LiteralExpression;
return { return {
'LiteralExpression.encodeLiteral works as expected': function (test) { 'LiteralExpression has an expand method': function (test) {
test.equal(typeof LiteralExpression.encodeLiteral, 'function'); test.equal(typeof LiteralExpression.prototype.expand, 'function');
test.equal(LiteralExpression.encodeLiteral('a b'), 'a%20b');
test.equal(LiteralExpression.encodeLiteral('a%20b'), 'a%20b');
test.done(); test.done();
} }
}; };
......
...@@ -5,6 +5,7 @@ module.exports = (function () { ...@@ -5,6 +5,7 @@ module.exports = (function () {
var var
sandbox = require('nodeunit').utils.sandbox, sandbox = require('nodeunit').utils.sandbox,
context = {}; context = {};
sandbox('src/UriTemplateError.js', context);
sandbox('src/objectHelper.js', context); sandbox('src/objectHelper.js', context);
sandbox('src/charHelper.js', context); sandbox('src/charHelper.js', context);
sandbox('src/pctEncoder.js', context); sandbox('src/pctEncoder.js', context);
......
module.exports = (function () {
"use strict";
var context = {};
require('nodeunit').utils.sandbox('src/UriTemplateError.js', context);
var UriTemplateError = context.UriTemplateError;
return {
"meaningful toString": function (test) {
var error = new UriTemplateError({});
test.equal(error.toString().indexOf('object'), -1);
test.done();
}
};
}());
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