Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

encode uri: Matrix urls, semicolons fix 4065 #4067

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ngResource/resource.js
Expand Up @@ -307,6 +307,7 @@ angular.module('ngResource', ['ng']).
function encodeUriSegment(val) {
return encodeUriQuery(val, true).
replace(/%26/gi, '&').
replace(/%3B/gi, ';').
replace(/%3D/gi, '=').
replace(/%2B/gi, '+');
}
Expand Down
12 changes: 12 additions & 0 deletions test/ngResource/resourceSpec.js
Expand Up @@ -137,6 +137,18 @@ describe("resource", function() {
});


it('should not encode ; in url params', function() {
//encodeURIComponent is too agressive and doesn't follow http://www.ietf.org/rfc/rfc3986.txt
//with regards to the character set (pchar) allowed in path segments
//so we need this test to make sure that we don't over-encode the params and break stuff like
//buzz api which uses @self

var R = $resource('/Path/:a/semicolon');
$httpBackend.expect('GET', '/Path/a=a;b=b;c=x/semicolon').respond('{}');
R.get({a: 'a=a;b=b;c=x'});
});


it('should encode array params', function() {
var R = $resource('/Path/:a');
$httpBackend.expect('GET', '/Path/doh&foo?bar=baz1&bar=baz2').respond('{}');
Expand Down