0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(ui): replace plain search string concatenate (#3663)

replace plain search string concatenate with URLSearchParams instances
This commit is contained in:
simeng-li 2023-04-03 17:41:22 +08:00 committed by GitHub
parent 94e03f2768
commit 964e078c3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,16 +8,14 @@ const useSocialCallbackHandler = () => {
const socialCallbackHandler = useCallback(
(connectorId: string) => {
// Get search string to evaluate
const searchString = window.location.search;
// Get search parameter to evaluate
const searchParams = new URLSearchParams(window.location.search);
// Get hash parameter to evaluate
const hashParams = new URLSearchParams(window.location.hash.slice(1));
// Get hash string to evaluate
const hashString = window.location.hash;
// Define evaluated search string
const search = `${searchString || '?'}${
searchString && hashString ? '&' : ''
}${hashString.slice(1)}`;
// Join search and hash parameters
const joinedSearchParams = new URLSearchParams([...searchParams, ...hashParams]);
const search = joinedSearchParams.toString() ? `?${joinedSearchParams.toString()}` : '';
// Get native callback link from storage
const callbackLink = getCallbackLinkFromStorage(connectorId);