Skip to content

Commit 5510b09

Browse files
Merge branch 'swisstofu-master'
2 parents ad3c845 + 54adfed commit 5510b09

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/urlMatcherFactorySpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,22 @@ describe("UrlMatcher", function () {
163163
var m = new UrlMatcher('/users/:id/details/{type}/{repeat:[0-9]+}?from&to');
164164
expect(m.exec('/users/123/details/what/thisShouldBeDigits', {})).toBeNull();
165165
});
166+
167+
it("should not use optional regexp for '/'", function () {
168+
var m = new UrlMatcher('/{language:(?:fr|en|de)}');
169+
expect(m.exec('/', {})).toBeNull();
170+
});
171+
172+
it("should work with empty default value", function () {
173+
var m = new UrlMatcher('/foo/:str', { params: { str: { value: "" } } });
174+
expect(m.exec('/foo/', {})).toEqual({ str: "" });
175+
});
166176

177+
it("should work with empty default value for regex", function () {
178+
var m = new UrlMatcher('/foo/{param:(?:foo|bar|)}', { params: { param: { value: "" } } });
179+
expect(m.exec('/foo/', {})).toEqual({ param: "" });
180+
});
181+
167182
it("should treat the URL as already decoded and does not decode it further", function () {
168183
expect(new UrlMatcher('/users/:id').exec('/users/100%25', {})).toEqual({ id: '100%25'});
169184
});

0 commit comments

Comments
 (0)