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

Function isSafeOriginChange

packages/platform-server/src/url.ts:172–189  ·  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

170 * @returns True if the origin has changed in a safe way, false otherwise.
171 */
172function isSafeOriginChange(
173 resolved: URL,
174 origin: URL,
175 urlStr: string,
176 allowOriginChange: boolean,
177): boolean {
178 if (origin.origin === resolved.origin) {
179 return true;
180 }
181
182 if (!allowOriginChange) {
183 return false;
184 }
185
186 return (
187 HTTP_OR_HTTPS_PROTOCOL_REGEXP.test(urlStr) && !HTTP_OR_HTTPS_NO_AUTHORITY_REGEXP.test(urlStr)
188 );
189}

Callers 1

resolveUrlFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected