MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / urlIsAllowedOriginFactory

Function urlIsAllowedOriginFactory

lib/test/angular/1.7.0/angular.js:21064–21081  ·  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

21062 * whether it is of an allowed origin.
21063 */
21064function urlIsAllowedOriginFactory(whitelistedOriginUrls) {
21065 var parsedAllowedOriginUrls = [originUrl].concat(whitelistedOriginUrls.map(urlResolve));
21066
21067 /**
21068 * Check whether the specified URL (string or parsed URL object) has an origin that is allowed
21069 * based on a list of whitelisted-origin URLs. The current location's origin is implicitly
21070 * trusted.
21071 *
21072 * @param {string|Object} requestUrl - The URL to be checked (provided as a string that will be
21073 * resolved or a parsed URL object).
21074 *
21075 * @returns {boolean} - Whether the specified URL is of an allowed origin.
21076 */
21077 return function urlIsAllowedOrigin(requestUrl) {
21078 var parsedUrl = urlResolve(requestUrl);
21079 return parsedAllowedOriginUrls.some(urlsAreSameOrigin.bind(null, parsedUrl));
21080 };
21081}
21082
21083/**
21084 * Determine if two URLs share the same origin.

Callers 1

$HttpProviderFunction · 0.70

Calls 1

urlResolveFunction · 0.70

Tested by

no test coverage detected