Skip to content

Commit

Permalink
fix: pass base to URL only when value is provided (#32)
Browse files Browse the repository at this point in the history
On Safari attempting to pass `base` as `undefined` results with `TypeError` as seen on https://responsive-ng-router.netlify.app.
Based on type definition for URL, `base` property is optional and of type `string | URL`. While most browsers consider passing undefined and omitting the property same, Safari is somewhat strict in this matter and throws an exception.
  • Loading branch information
meeroslav committed Jul 22, 2020
1 parent 86babd9 commit 3810e3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/angular-routing/src/lib/url-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Injectable } from '@angular/core';
@Injectable()
export class UrlParser {
parse(url: string, base?: string | URL): URL {
return new URL(url, base);
if (base) {
return new URL(url, base);
}
return new URL(url);
}

joinUrls(currentUrl: string, url: string): string {
Expand Down

0 comments on commit 3810e3b

Please sign in to comment.