diff --git a/.changeset/tricky-rabbits-sparkle.md b/.changeset/tricky-rabbits-sparkle.md new file mode 100644 index 00000000000..f1d456c1b1d --- /dev/null +++ b/.changeset/tricky-rabbits-sparkle.md @@ -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. diff --git a/packages/clerk-js/src/utils/windowNavigate.ts b/packages/clerk-js/src/utils/windowNavigate.ts index 1d440882d8d..b8abdb89549 100644 --- a/packages/clerk-js/src/utils/windowNavigate.ts +++ b/packages/clerk-js/src/utils/windowNavigate.ts @@ -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); }