Skip to content

Commit 0c983a0

Browse files
fix($urlMatcherFactory): fix encoding slashes in params
Closes #1119
1 parent 831d812 commit 0c983a0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/urlMatcherFactory.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ function $UrlMatcherFactory() {
561561

562562
var isCaseInsensitive = false, isStrictMode = true, defaultSquashPolicy = false;
563563

564-
function valToString(val) { return val != null ? val.toString().replace("/", "%2F") : val; }
565-
function valFromString(val) { return val != null ? val.toString().replace("%2F", "/") : val; }
564+
function valToString(val) { return val != null ? val.toString().replace(/\//g, "%2F") : val; }
565+
function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, "/") : val; }
566566
function angularEquals(left, right) { return angular.equals(left, right); }
567567
// TODO: in 1.0, make string .is() return false if value is undefined by default.
568568
// function regexpMatches(val) { /*jshint validthis:true */ return isDefined(val) && this.pattern.test(val); }

test/urlMatcherFactorySpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ describe("UrlMatcher", function () {
6161
expect(matcher.format(array)).toBe('/?foo=bar&foo=baz');
6262
});
6363

64+
it("should encode and decode slashes in parameter values", function () {
65+
var matcher = new UrlMatcher('/:foo');
66+
expect(matcher.format({ foo: "/" })).toBe('/%252F');
67+
expect(matcher.format({ foo: "//" })).toBe('/%252F%252F');
68+
});
69+
6470
describe("snake-case parameters", function() {
6571
it("should match if properly formatted", function() {
6672
var matcher = new UrlMatcher('/users/?from&to&snake-case&snake-case-triple');

0 commit comments

Comments
 (0)