MCPcopy
hub / github.com/angular-ui/ui-router / $HttpParamSerializerProvider

Function $HttpParamSerializerProvider

test/angular/1.6/angular.js:11328–11363  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

11326
11327/** @this */
11328function $HttpParamSerializerProvider() {
11329 /**
11330 * @ngdoc service
11331 * @name $httpParamSerializer
11332 * @description
11333 *
11334 * Default {@link $http `$http`} params serializer that converts objects to strings
11335 * according to the following rules:
11336 *
11337 * * `{'foo': 'bar'}` results in `foo=bar`
11338 * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
11339 * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
11340 * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D` (stringified and encoded representation of an object)
11341 *
11342 * Note that serializer will sort the request parameters alphabetically.
11343 */
11344
11345 this.$get = function() {
11346 return function ngParamSerializer(params) {
11347 if (!params) return '';
11348 var parts = [];
11349 forEachSorted(params, function(value, key) {
11350 if (value === null || isUndefined(value) || isFunction(value)) return;
11351 if (isArray(value)) {
11352 forEach(value, function(v) {
11353 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));
11354 });
11355 } else {
11356 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value)));
11357 }
11358 });
11359
11360 return parts.join('&');
11361 };
11362 };
11363}
11364
11365/** @this */
11366function $HttpParamSerializerJQLikeProvider() {

Callers

nothing calls this directly

Calls 7

isArrayFunction · 0.85
forEachSortedFunction · 0.70
isUndefinedFunction · 0.70
isFunctionFunction · 0.70
forEachFunction · 0.70
encodeUriQueryFunction · 0.70
serializeValueFunction · 0.70

Tested by

no test coverage detected