MCPcopy Create free account
hub / github.com/angular/angular / isSafeOriginChange

Function isSafeOriginChange

packages/platform-server/src/url.ts:146–163  ·  view source on GitHub ↗

* Checks if the origin has changed in a safe way. * * @param resolved The resolved URL. * @param origin The origin URL. * @param urlStr The URL string. * @param allowOriginChange Whether to allow origin changes. * @returns True if the origin has changed in a safe way, false otherwise.

(
  resolved: URL,
  origin: URL,
  urlStr: string,
  allowOriginChange: boolean,
)

Source from the content-addressed store, hash-verified

144 * @returns True if the origin has changed in a safe way, false otherwise.
145 */
146function isSafeOriginChange(
147 resolved: URL,
148 origin: URL,
149 urlStr: string,
150 allowOriginChange: boolean,
151): boolean {
152 if (origin.origin === resolved.origin) {
153 return true;
154 }
155
156 if (!allowOriginChange) {
157 return false;
158 }
159
160 return (
161 HTTP_OR_HTTPS_PROTOCOL_REGEXP.test(urlStr) && !HTTP_OR_HTTPS_NO_AUTHORITY_REGEXP.test(urlStr)
162 );
163}

Callers 1

resolveUrlFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected