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

Commit c12f525

Browse files
cakesifupkozlowski-opensource
authored andcommitted
refactor($resource): fix indentation and move a method definition
Moved Resource.bind out of the actions forEach
1 parent e7ba830 commit c12f525

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

src/ngResource/resource.js

+46-46
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @description
77
*/
88

9-
/**
9+
/**
1010
* @ngdoc object
1111
* @name ngResource.$resource
1212
* @requires $http
@@ -224,46 +224,46 @@ angular.module('ngResource', ['ng']).
224224
return $parse(path)(obj);
225225
};
226226

227-
/**
228-
* We need our custom mehtod because encodeURIComponent is too aggressive and doesn't follow
229-
* http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path
230-
* segments:
231-
* segment = *pchar
232-
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
233-
* pct-encoded = "%" HEXDIG HEXDIG
234-
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
235-
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
236-
* / "*" / "+" / "," / ";" / "="
237-
*/
238-
function encodeUriSegment(val) {
239-
return encodeUriQuery(val, true).
240-
replace(/%26/gi, '&').
241-
replace(/%3D/gi, '=').
242-
replace(/%2B/gi, '+');
243-
}
244-
245-
246-
/**
247-
* This method is intended for encoding *key* or *value* parts of query component. We need a custom
248-
* method becuase encodeURIComponent is too agressive and encodes stuff that doesn't have to be
249-
* encoded per http://tools.ietf.org/html/rfc3986:
250-
* query = *( pchar / "/" / "?" )
251-
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
252-
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
253-
* pct-encoded = "%" HEXDIG HEXDIG
254-
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
255-
* / "*" / "+" / "," / ";" / "="
256-
*/
257-
function encodeUriQuery(val, pctEncodeSpaces) {
258-
return encodeURIComponent(val).
259-
replace(/%40/gi, '@').
260-
replace(/%3A/gi, ':').
261-
replace(/%24/g, '$').
262-
replace(/%2C/gi, ',').
263-
replace((pctEncodeSpaces ? null : /%20/g), '+');
264-
}
265-
266-
function Route(template, defaults) {
227+
/**
228+
* We need our custom mehtod because encodeURIComponent is too aggressive and doesn't follow
229+
* http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path
230+
* segments:
231+
* segment = *pchar
232+
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
233+
* pct-encoded = "%" HEXDIG HEXDIG
234+
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
235+
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
236+
* / "*" / "+" / "," / ";" / "="
237+
*/
238+
function encodeUriSegment(val) {
239+
return encodeUriQuery(val, true).
240+
replace(/%26/gi, '&').
241+
replace(/%3D/gi, '=').
242+
replace(/%2B/gi, '+');
243+
}
244+
245+
246+
/**
247+
* This method is intended for encoding *key* or *value* parts of query component. We need a custom
248+
* method becuase encodeURIComponent is too agressive and encodes stuff that doesn't have to be
249+
* encoded per http://tools.ietf.org/html/rfc3986:
250+
* query = *( pchar / "/" / "?" )
251+
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
252+
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
253+
* pct-encoded = "%" HEXDIG HEXDIG
254+
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
255+
* / "*" / "+" / "," / ";" / "="
256+
*/
257+
function encodeUriQuery(val, pctEncodeSpaces) {
258+
return encodeURIComponent(val).
259+
replace(/%40/gi, '@').
260+
replace(/%3A/gi, ':').
261+
replace(/%24/g, '$').
262+
replace(/%2C/gi, ',').
263+
replace((pctEncodeSpaces ? null : /%20/g), '+');
264+
}
265+
266+
function Route(template, defaults) {
267267
this.template = template = template + '#';
268268
this.defaults = defaults || {};
269269
var urlParams = this.urlParams = {};
@@ -390,11 +390,6 @@ angular.module('ngResource', ['ng']).
390390
};
391391

392392

393-
Resource.bind = function(additionalParamDefaults){
394-
return ResourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions);
395-
};
396-
397-
398393
Resource.prototype['$' + name] = function(a1, a2, a3) {
399394
var params = extractParams(this),
400395
success = noop,
@@ -420,6 +415,11 @@ angular.module('ngResource', ['ng']).
420415
Resource[name].call(this, params, data, success, error);
421416
};
422417
});
418+
419+
Resource.bind = function(additionalParamDefaults){
420+
return ResourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions);
421+
};
422+
423423
return Resource;
424424
}
425425

0 commit comments

Comments
 (0)