diff --git a/packages/common/upgrade/src/params.ts b/packages/common/upgrade/src/params.ts index 025c2edcaa..d1f7917ff6 100644 --- a/packages/common/upgrade/src/params.ts +++ b/packages/common/upgrade/src/params.ts @@ -198,7 +198,8 @@ export class AngularJSUrlCodec implements UrlCodec { // https://github.com/angular/angular.js/blob/864c7f0/src/ng/urlUtils.js#L60 parse(url: string, base?: string) { try { - const parsed = new URL(url, base); + // Safari 12 throws an error when the URL constructor is called with an undefined base. + const parsed = !base ? new URL(url) : new URL(url, base); return { href: parsed.href, protocol: parsed.protocol ? parsed.protocol.replace(/:$/, '') : '', @@ -335,4 +336,4 @@ function encodeUriQuery(val: string, pctEncodeSpaces: boolean = false) { .replace(/%2C/gi, ',') .replace(/%3B/gi, ';') .replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); -} \ No newline at end of file +}