Skip to content

Commit

Permalink
Safe url hash build (#239)
Browse files Browse the repository at this point in the history
* chore(clerk-js): Introduce a pathJoin utility

* chore(clerk-js): Enhance buildURL utility

BuildURL can no build a URL safely by using the native URL() constructor. It can also build a secondary path and search URL that lives inside the hash of the main URL.

For example:

https://foo.com/bar?qux=42#/hash-bar?hash-qux=42

This is very useful when we need to navigate across pages or between components in a safe way and avoid string concatenations in URLs.

* fix(clerk-js): Fix navigateToFactorTwo

Navigating to two factor after a sign up transfer flow was broken when the sign in URL contained querystring parameters such as redirect_url or after_sign_up_url.

The culprit was the string concatenation was used to build the final factor-two url as we were appending the #/factor-two string after the query strings.

This PR fixes the issue by leveraging the new, smarter buildURL utility.
  • Loading branch information
SokratisVidros authored and yourtallness committed May 13, 2022
1 parent 658391a commit f8943f6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/clerk-js/src/ui/signUp/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { VerifyMagicLink } from 'ui/common';
import { SSOCallback } from 'ui/common/SSOCallback';
import { ComponentContext, useCoreClerk, useSignUpContext, withCoreSessionSwitchGuard } from 'ui/contexts';
import { Route, Switch, VIRTUAL_ROUTER_BASE_PATH } from 'ui/router';
import { buildURL } from 'utils/url';

import { SignUpStart } from './SignUpStart';
import { SignUpVerifyEmailAddress, SignUpVerifyPhoneNumber } from './SignUpVerify';
Expand Down

0 comments on commit f8943f6

Please sign in to comment.