MCPcopy
hub / github.com/angular-ui/ui-grid / urlIsAllowedOriginFactory

Function urlIsAllowedOriginFactory

lib/test/angular/1.8.0/angular.js:21850–21867  ·  view source on GitHub ↗

* Create a function that can check a URL's origin against a list of allowed/whitelisted origins. * The current location's origin is implicitly trusted. * * @param {string[]} whitelistedOriginUrls - A list of URLs (strings), whose origins are trusted. * * @returns {Function} - A function that re

(whitelistedOriginUrls)

Source from the content-addressed store, hash-verified

21848 * whether it is of an allowed origin.
21849 */
21850function urlIsAllowedOriginFactory(whitelistedOriginUrls) {
21851 var parsedAllowedOriginUrls = [originUrl].concat(whitelistedOriginUrls.map(urlResolve));
21852
21853 /**
21854 * Check whether the specified URL (string or parsed URL object) has an origin that is allowed
21855 * based on a list of whitelisted-origin URLs. The current location's origin is implicitly
21856 * trusted.
21857 *
21858 * @param {string|Object} requestUrl - The URL to be checked (provided as a string that will be
21859 * resolved or a parsed URL object).
21860 *
21861 * @returns {boolean} - Whether the specified URL is of an allowed origin.
21862 */
21863 return function urlIsAllowedOrigin(requestUrl) {
21864 var parsedUrl = urlResolve(requestUrl);
21865 return parsedAllowedOriginUrls.some(urlsAreSameOrigin.bind(null, parsedUrl));
21866 };
21867}
21868
21869/**
21870 * Determine if two URLs share the same origin.

Callers 1

$HttpProviderFunction · 0.70

Calls 1

urlResolveFunction · 0.70

Tested by

no test coverage detected