Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/tricky-rabbits-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@clerk/clerk-js": patch
---

In a previous release the protocol validation for window navigation was added ([ref](https://github.com/clerk/javascript/commit/b91e0ef4036d215da09d144f85b0a5ef2afe6cba)). Since then only `http:` and `https:` were allowed.

With this release `wails:` is also supported again. If you think that the mentioned commit introduced a regression for you and your protocol should be supported, please open an issue.
13 changes: 11 additions & 2 deletions packages/clerk-js/src/utils/windowNavigate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
export const CLERK_BEFORE_UNLOAD_EVENT = 'clerk:beforeunload';

const ALLOWED_PROTOCOLS = [
'http:',
'https:',
// Refers to https://wails.io/
'wails:',
];

export function windowNavigate(to: URL | string): void {
let toURL = new URL(to, window.location.href);

if (toURL.protocol !== 'http:' && toURL.protocol !== 'https:') {
console.warn('Clerk: Not a valid protocol. Redirecting to /');
if (!ALLOWED_PROTOCOLS.includes(toURL.protocol)) {
console.warn(
`Clerk: "${toURL.protocol}" is not a valid protocol. Redirecting to "/" instead. If you think this is a mistake, please open an issue.`,
);
toURL = new URL('/', window.location.href);
}

Expand Down