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

Function $HttpParamSerializerProvider

test/angular/1.5/angular.js:10759–10794  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

10757
10758/** @this */
10759function $HttpParamSerializerProvider() {
10760 /**
10761 * @ngdoc service
10762 * @name $httpParamSerializer
10763 * @description
10764 *
10765 * Default {@link $http `$http`} params serializer that converts objects to strings
10766 * according to the following rules:
10767 *
10768 * * `{'foo': 'bar'}` results in `foo=bar`
10769 * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)
10770 * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)
10771 * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D` (stringified and encoded representation of an object)
10772 *
10773 * Note that serializer will sort the request parameters alphabetically.
10774 * */
10775
10776 this.$get = function() {
10777 return function ngParamSerializer(params) {
10778 if (!params) return '';
10779 var parts = [];
10780 forEachSorted(params, function(value, key) {
10781 if (value === null || isUndefined(value)) return;
10782 if (isArray(value)) {
10783 forEach(value, function(v) {
10784 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));
10785 });
10786 } else {
10787 parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value)));
10788 }
10789 });
10790
10791 return parts.join('&');
10792 };
10793 };
10794}
10795
10796/** @this */
10797function $HttpParamSerializerJQLikeProvider() {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected