Fix target not being added if source does not look like a source.

This commit is contained in:
André Cruz
2013-08-20 21:48:26 +01:00
parent 766dcd0dd5
commit 52938202bd
2 changed files with 9 additions and 3 deletions

View File

@@ -92,9 +92,9 @@ function decomposed2json(decEndpoint) {
// If value is empty, we append the target always
if (!value) {
value += isWildcard(target) ? '*' : target;
// Otherwise append only if not a wildcard
} else if (!isWildcard(target)) {
value += '#' + target;
// Otherwise append only if not a wildcard or source does not look like a source
} else if (!isWildcard(target) || !isSource(source)) {
value += '#' + (target || '*');
}
ret[name] = value;

View File

@@ -181,6 +181,8 @@ describe('endpoint-parser', function () {
{ bar: '*' },
{ baz: '*' },
{ jqueryx: 'jquery#~1.9.1' },
{ jqueryy: 'jquery-x#*' },
{ jqueryy: 'jquery-x#*' },
{ backbone: 'backbone-amd#~1.0.0' },
{ backbone : 'backbone=backbone-amd#~1.0.0' },
{ bootstrap: 'http://twitter.github.io/bootstrap/assets/bootstrap' },
@@ -196,6 +198,8 @@ describe('endpoint-parser', function () {
{ name: 'bar', source: 'bar', target: '*' },
{ name: 'baz', source: 'baz', target: '' },
{ name: 'jqueryx', source: 'jquery', target: '~1.9.1' },
{ name: 'jqueryy', source: 'jquery-x', target: '' },
{ name: 'jqueryy', source: 'jquery-x', target: '*' },
{ name: 'backbone', source: 'backbone-amd', target: '~1.0.0' },
{ name: 'backbone', source: 'backbone=backbone-amd', target: '~1.0.0' },
{ name: 'bootstrap', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '' },
@@ -218,6 +222,8 @@ describe('endpoint-parser', function () {
{ name: 'bar', source: 'bar ', target: ' * ' },
{ name: 'baz ', source: 'baz', target: ' ' },
{ name: ' jqueryx ', source: ' jquery ', target: ' ~1.9.1 ' },
{ name: ' jqueryy ', source: ' jquery-x ', target: ' ' },
{ name: ' jqueryy ', source: ' jquery-x ', target: ' * ' },
{ name: ' backbone ', source: ' backbone-amd ', target: ' ~1.0.0 ' },
{ name: ' backbone ', source: ' backbone=backbone-amd ', target: ' ~1.0.0 ' },
{ name: ' bootstrap ', source: ' http://twitter.github.io/bootstrap/assets/bootstrap ', target: ' ' },