mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
fix(core): avoid extra redirect proxy (#8252)
This commit is contained in:
@@ -1,8 +1,18 @@
|
|||||||
export function popupWindow(target: string) {
|
export function popupWindow(target: string) {
|
||||||
const url = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
|
|
||||||
target = /^https?:\/\//.test(target)
|
target = /^https?:\/\//.test(target)
|
||||||
? target
|
? target
|
||||||
: BUILD_CONFIG.serverUrlPrefix + 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`);
|
return window.open(url, '_blank', `noreferrer noopener`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user