Skip to content

Commit

Permalink
Merge pull request #529 from igorkamyshev/fix-safari-14-0-issue-with-url
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev authored Jan 30, 2025
2 parents f13a916 + 5a28d32 commit 1f54e10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/heavy-otters-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farfetched/core": patch
---

Add workaround for Safari 14.0 bugged implementation of URL constructor
8 changes: 7 additions & 1 deletion packages/core/src/fetch/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ export function formatUrl(
urlString = `${url}?${queryString}`;
}

/**
* Workararound for Safari 14.0
* @see https://github.com/igorkamyshev/farfetched/issues/528
*/
const urlArgs = [urlString, urlBase].filter(Boolean) as [string, string];

try {
return new URL(urlString, urlBase);
return new URL(...urlArgs);
} catch (e) {
throw configurationError({
reason: 'Invalid URL',
Expand Down

0 comments on commit 1f54e10

Please sign in to comment.