-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow array parameters in query strings. For #1
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,3 +168,23 @@ Tinytest.add('Url - matching', function (test) { | |
test.isTrue(path.exec('/commits/123..456')); | ||
*/ | ||
}); | ||
|
||
Tinytest.add('Url - params', function (test) { | ||
var path = new Url(paths.explicit); | ||
test.isUndefined(path.params('/posts').foo); | ||
test.equal(path.params('/posts?foo=bar').foo, 'bar'); | ||
test.equal(path.params('/posts?foo[]=bar').foo, ['bar']); | ||
test.equal(path.params('/posts?foo%5B%5D=bar').foo, ['bar']); | ||
test.equal(path.params('/posts?foo[]=bar&foo[]=baz').foo, ['bar', 'baz']); | ||
test.equal(path.params('/posts?foo%5B%5D=bar&foo%5B%5D=baz').foo, ['bar', 'baz']); | ||
}); | ||
|
||
Tinytest.add('Url - resolve', function (test) { | ||
var path = new Url(paths.explicit); | ||
test.equal(path.resolve({}), '/posts'); | ||
test.equal(path.resolve({}, {query: {foo: 'bar'}}), '/posts?foo=bar'); | ||
test.equal(path.resolve({}, {query: {foo: ['bar']}}), '/posts?foo%5B%5D=bar'); | ||
test.equal(path.resolve({}, {query: {foo: ['bar', 'baz']}}), '/posts?foo%5B%5D=bar&foo%5B%5D=baz'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dburles
Contributor
|
||
// no good resolution of this one | ||
test.equal(path.resolve({}, {query: {foo: []}}), '/posts'); | ||
}); |
I'm not sure if the
[]
should be URL encoded or not. Do you have a read on this @cmather?