Skip to content

Commit 239033f

Browse files
author
Piotr Delinowski
committed
Merge branch 'my-fix-branch' of https://github.com/chliebel/ui-router
2 parents 2d23875 + 0b90362 commit 239033f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/urlMatcherFactory.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,9 @@ function $UrlMatcherFactory() {
579579
$$UMFP = this;
580580

581581
var isCaseInsensitive = false, isStrictMode = true, defaultSquashPolicy = false;
582+
var slashReplacement = "%2F";
582583

583-
function valToString(val) { return val != null ? val.toString().replace(/\//g, "%2F") : val; }
584+
function valToString(val) { return val != null ? val.toString().replace(/\//g, slashReplacement) : val; }
584585
function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, "/") : val; }
585586

586587
var $types = {}, enqueue = true, typeQueue = [], injector, defaultTypes = {
@@ -589,7 +590,7 @@ function $UrlMatcherFactory() {
589590
decode: valFromString,
590591
// TODO: in 1.0, make string .is() return false if value is undefined/null by default.
591592
// In 0.2.x, string params are optional by default for backwards compat
592-
is: function(val) { return val == null || !isDefined(val) || typeof val === "string"; },
593+
is: function(val) { return val == null || !isDefined(val) || (isString(val) && val.indexOf(slashReplacement) === -1); },
593594
pattern: /[^/]*/
594595
},
595596
int: {

test/urlMatcherFactorySpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ describe("UrlMatcher", function () {
6565
var matcher = new UrlMatcher('/:foo');
6666
expect(matcher.format({ foo: "/" })).toBe('/%252F');
6767
expect(matcher.format({ foo: "//" })).toBe('/%252F%252F');
68+
expect(matcher.exec('/hello%2Fworld')).toEqual({ foo: 'hello/world' });
6869
});
6970

7071
describe("snake-case parameters", function() {

0 commit comments

Comments
 (0)