mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-28 19:50:34 +00:00
21 lines
No EOL
844 B
JavaScript
21 lines
No EOL
844 B
JavaScript
// src/utils/url.ts
|
|
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
|
|
function constructRedirectUrl(redirectUrl, callbackUrlName) {
|
|
if (typeof window === "undefined" || !window.location) {
|
|
throw new StackAssertionError(`${callbackUrlName} option is required in a non-browser environment.`, { redirectUrl });
|
|
}
|
|
const retainedQueryParams = ["after_auth_return_to"];
|
|
const currentUrl = new URL(window.location.href);
|
|
const url = redirectUrl ? new URL(redirectUrl, window.location.href) : new URL(window.location.href);
|
|
for (const param of retainedQueryParams) {
|
|
if (currentUrl.searchParams.has(param)) {
|
|
url.searchParams.set(param, currentUrl.searchParams.get(param));
|
|
}
|
|
}
|
|
url.hash = "";
|
|
return url.toString();
|
|
}
|
|
export {
|
|
constructRedirectUrl
|
|
};
|
|
//# sourceMappingURL=url.js.map
|