PageSourceSearch

https://www.ciencia.gob.es/.resources/site-web/webresources/js/url…/index~2026-09-16-05-38-57-120~cache.js

js ciencia.gob.es collected 2026-10-01 10:15:14 UTC 10,889 bytes, 349 lines download raw bytes

vendor: 10,889 bytes, lines 1-349
1/**
2 *
3 *
4 * @author Jerry Bendy <[email protected]>
5 * @licence MIT
6 *
7 */
8
9(function(self) {
10    'use strict';
11
12    var nativeURLSearchParams = (function() {
13            // #41 Fix issue in RN
14            try {
15                if (self.URLSearchParams && (new self.URLSearchParams('foo=bar')).get('foo') === 'bar') {
16                    return self.URLSearchParams;
17                }
18            } catch (e) {}
19            return null;
20        })(),
21        isSupportObjectConstructor = nativeURLSearchParams && (new nativeURLSearchParams({a: 1})).toString() === 'a=1',
22        // There is a bug in safari 10.1 (and earlier) that incorrectly decodes `%2B` as an empty space and not a plus.
23        decodesPlusesCorrectly = nativeURLSearchParams && (new nativeURLSearchParams('s=%2B').get('s') === '+'),
24        __URLSearchParams__ = "__URLSearchParams__",
25        // Fix bug in Edge which cannot encode ' &' correctly
26        encodesAmpersandsCorrectly = nativeURLSearchParams ? (function() {
27            var ampersandTest = new nativeURLSearchParams();
28            ampersandTest.append('s', ' &');
29            return ampersandTest.toString() === 's=+%26';
30        })() : true,
31        prototype = URLSearchParamsPolyfill.prototype,
32        iterable = !!(self.Symbol && self.Symbol.iterator);
33
34    if (nativeURLSearchParams && isSupportObjectConstructor && decodesPlusesCorrectly && encodesAmpersandsCorrectly) {
35        return;
36    }
37
38
39    /**
40     * Make a URLSearchParams instance
41     *
42     * @param {object|string|URLSearchParams} search
43     * @constructor
44     */
45    function URLSearchParamsPolyfill(search) {
46        search = search || "";
47
48        // support construct object with another URLSearchParams instance
49        if (search instanceof URLSearchParams || search instanceof URLSearchParamsPolyfill) {
50            search = search.toString();
51        }
52        this [__URLSearchParams__] = parseToDict(search);
53    }
54
55
56    /**
57     * Appends a specified key/value pair as a new search parameter.
58     *
59     * @param {string} name
60     * @param {string} value
61     */
62    prototype.append = function(name, value) {
63        appendTo(this [__URLSearchParams__], name, value);
64    };
65
66    /**
67     * Deletes the given search parameter, and its associated value,
68     * from the list of all search parameters.
69     *
70     * @param {string} name
71     */
72    prototype['delete'] = function(name) {
73        delete this [__URLSearchParams__] [name];
74    };
75
76    /**
77     * Returns the first value associated to the given search parameter.
78     *
79     * @param {string} name
80     * @returns {string|null}
81     */
82    prototype.get = function(name) {
83        var dict = this [__URLSearchParams__];
84        return this.has(name) ? dict[name][0] : null;
85    };
86
87    /**
88     * Returns all the values association with a given search parameter.
89     *
90     * @param {string} name
91     * @returns {Array}
92     */
93    prototype.getAll = function(name) {
94        var dict = this [__URLSearchParams__];
95        return this.has(name) ? dict [name].slice(0) : [];
96    };
97
98    /**
99     * Returns a Boolean indicating if such a search parameter exists.
100     *
101     * @param {string} name
102     * @returns {boolean}
103     */
104    prototype.has = function(name) {
105        return hasOwnProperty(this [__URLSearchParams__], name);
106    };
107
108    /**
109     * Sets the value associated to a given search parameter to
110     * the given value. If there were several values, delete the
111     * others.
112     *
113     * @param {string} name
114     * @param {string} value
115     */
116    prototype.set = function set(name, value) {
117        this [__URLSearchParams__][name] = ['' + value];
118    };
119
120    /**
121     * Returns a string containg a query string suitable for use in a URL.
122     *
123     * @returns {string}
124     */
125    prototype.toString = function() {
126        var dict = this[__URLSearchParams__], query = [], i, key, name, value;
127        for (key in dict) {
128            name = encode(key);
129            for (i = 0, value = dict[key]; i < value.length; i++) {
130                query.push(name + '=' + encode(value[i]));
131            }
132        }
133        return query.join('&');
134    };
135
136    // There is a bug in Safari 10.1 and `Proxy`ing it is not enough.
137    var forSureUsePolyfill = !decodesPlusesCorrectly;
138    var useProxy = (!forSureUsePolyfill && nativeURLSearchParams && !isSupportObjectConstructor && self.Proxy);
139    /*
140     * Apply polifill to global object and append other prototype into it
141     */
142    Object.defineProperty(self, 'URLSearchParams', {
143        value: (useProxy ?
144            // Safari 10.0 doesn't support Proxy, so it won't extend URLSearchParams on safari 10.0
145            new Proxy(nativeURLSearchParams, {
146                construct: function(target, args) {
147                    return new target((new URLSearchParamsPolyfill(args[0]).toString()));
148                }
149            }) :
150            URLSearchParamsPolyfill)
151    });
152
153    var USPProto = self.URLSearchParams.prototype;
154
155    USPProto.polyfill = true;
156
157    /**
158     *
159     * @param {function} callback
160     * @param {object} thisArg
161     */
162    USPProto.forEach = USPProto.forEach || function(callback, thisArg) {
163        var dict = parseToDict(this.toString());
164        Object.getOwnPropertyNames(dict).forEach(function(name) {
165            dict[name].forEach(function(value) {
166                callback.call(thisArg, value, name, this);
167            }, this);
168        }, this);
169    };
170
171    /**
172     * Sort all name-value pairs
173     */
174    USPProto.sort = USPProto.sort || function() {
175        var dict = parseToDict(this.toString()), keys = [], k, i, j;
176        for (k in dict) {
177            keys.push(k);
178        }
179        keys.sort();
180
181        for (i = 0; i < keys.length; i++) {
182            this['delete'](keys[i]);
183        }
184        for (i = 0; i < keys.length; i++) {
185            var key = keys[i], values = dict[key];
186            for (j = 0; j < values.length; j++) {
187                this.append(key, values[j]);
188            }
189        }
190    };
191
192    /**
193     * Returns an iterator allowing to go through all keys of
194     * the key/value pairs contained in this object.
195     *
196     * @returns {function}
197     */
198    USPProto.keys = USPProto.keys || function() {
199        var items = [];
200        this.forEach(function(item, name) {
201            items.push(name);
202        });
203        return makeIterator(items);
204    };
205
206    /**
207     * Returns an iterator allowing to go through all values of
208     * the key/value pairs contained in this object.
209     *
210     * @returns {function}
211     */
212    USPProto.values = USPProto.values || function() {
213        var items = [];
214        this.forEach(function(item) {
215            items.push(item);
216        });
217        return makeIterator(items);
218    };
219
220    /**
221     * Returns an iterator allowing to go through all key/value
222     * pairs contained in this object.
223     *
224     * @returns {function}
225     */
226    USPProto.entries = USPProto.entries || function() {
227        var items = [];
228        this.forEach(function(item, name) {
229            items.push([name, item]);
230        });
231        return makeIterator(items);
232    };
233
234
235    if (iterable) {
236        USPProto[self.Symbol.iterator] = USPProto[self.Symbol.iterator] || USPProto.entries;
237    }
238
239
240    function encode(str) {
241        var replace = {
242            '!': '%21',
243            "'": '%27',
244            '(': '%28',
245            ')': '%29',
246            '~': '%7E',
247            '%20': '+',
248            '%00': '\x00'
249        };
250        return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function(match) {
251            return replace[match];
252        });
253    }
254
255    function decode(str) {
256        return str
257            .replace(/[ +]/g, '%20')
258            .replace(/(%[a-f0-9]{2})+/ig, function(match) {
259                return decodeURIComponent(match);
260            });
261    }
262
263    function makeIterator(arr) {
264        var iterator = {
265            next: function() {
266                var value = arr.shift();
267                return {done: value === undefined, value: value};
268            }
269        };
270
271        if (iterable) {
272            iterator[self.Symbol.iterator] = function() {
273                return iterator;
274            };
275        }
276
277        return iterator;
278    }
279
280    function parseToDict(search) {
281        var dict = {};
282
283        if (typeof search === "object") {
284            // if `search` is an array, treat it as a sequence
285            if (isArray(search)) {
286                for (var i = 0; i < search.length; i++) {
287                    var item = search[i];
288                    if (isArray(item) && item.length === 2) {
289                        appendTo(dict, item[0], item[1]);
290                    } else {
291                        throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
292                    }
293                }
294
295            } else {
296                for (var key in search) {
297                    if (search.hasOwnProperty(key)) {
298                        appendTo(dict, key, search[key]);
299                    }
300                }
301            }
302
303        } else {
304            // remove first '?'
305            if (search.indexOf("?") === 0) {
306                search = search.slice(1);
307            }
308
309            var pairs = search.split("&");
310            for (var j = 0; j < pairs.length; j++) {
311                var value = pairs [j],
312                    index = value.indexOf('=');
313
314                if (-1 < index) {
315                    appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
316
317                } else {
318                    if (value) {
319                        appendTo(dict, decode(value), '');
320                    }
321                }
322            }
323        }
324
325        return dict;
326    }
327
328    function appendTo(dict, name, value) {
329        var val = typeof value === 'string' ? value : (
330            value !== null && value !== undefined && typeof value.toString === 'function' ? value.toString() : JSON.stringify(value)
331        );
332
333        // #47 Prevent using `hasOwnProperty` as a property name
334        if (hasOwnProperty(dict, name)) {
335            dict[name].push(val);
336        } else {
337            dict[name] = [val];
338        }
339    }
340
341    function isArray(val) {
342        return !!val && '[object Array]' === Object.prototype.toString.call(val);
343    }
344
345    function hasOwnProperty(obj, prop) {
346        return Object.prototype.hasOwnProperty.call(obj, prop);
347    }
348
349})(typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : this));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.