aboutsummaryrefslogtreecommitdiffstats
path: root/src/Resource.js
diff options
context:
space:
mode:
authorIgor Minar2011-02-16 19:48:21 -0500
committerIgor Minar2011-02-17 23:06:53 -0800
commit9e30baad3feafc82fb2f2011fd3f21909f4ba29e (patch)
tree98bceb6601422c859b1f7cf326fdb77385593808 /src/Resource.js
parenta070ff5ad08450a1eb6375790fc90693d624e283 (diff)
downloadangular.js-9e30baad3feafc82fb2f2011fd3f21909f4ba29e.tar.bz2
resources should not over-encode chars in url path
- added encodeUriSegment that properly encodes only those chars that URI RFC requires us to encode - modified Resource to use encodeUriSegment
Diffstat (limited to 'src/Resource.js')
-rw-r--r--src/Resource.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Resource.js b/src/Resource.js
index e801d200..f748fb5a 100644
--- a/src/Resource.js
+++ b/src/Resource.js
@@ -13,19 +13,20 @@ function Route(template, defaults) {
Route.prototype = {
url: function(params) {
- var path = [];
- var self = this;
- var url = this.template;
+ var self = this,
+ url = this.template,
+ encodedVal;
+
params = params || {};
forEach(this.urlParams, function(_, urlParam){
- var value = params[urlParam] || self.defaults[urlParam] || "";
- url = url.replace(new RegExp(":" + urlParam + "(\\W)"), encodeURIComponent(value) + "$1");
+ encodedVal = encodeUriSegment(params[urlParam] || self.defaults[urlParam] || "")
+ url = url.replace(new RegExp(":" + urlParam + "(\\W)"), encodedVal + "$1");
});
url = url.replace(/\/?#$/, '');
var query = [];
forEachSorted(params, function(value, key){
if (!self.urlParams[key]) {
- query.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
+ query.push(encodeUriSegment(key) + '=' + encodeUriSegment(value));
}
});
url = url.replace(/\/*$/, '');