fix(core): avoid extra redirect proxy (#8252)

This commit is contained in:
forehalo
2024-09-14 01:35:59 +00:00
parent d2cb7b7683
commit ff15ea1eec

View File

@@ -1,8 +1,18 @@
export function popupWindow(target: string) {
const url = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
target = /^https?:\/\//.test(target)
? target
: BUILD_CONFIG.serverUrlPrefix + target;
url.searchParams.set('redirect_uri', target);
const targetUrl = new URL(target);
let url: string;
// safe to open directly if in the same origin
if (targetUrl.origin === location.origin) {
url = target;
} else {
const builder = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
builder.searchParams.set('redirect_uri', target);
url = builder.toString();
}
return window.open(url, '_blank', `noreferrer noopener`);
}