mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
fix(core): avoid extra redirect proxy (#8252)
This commit is contained in:
@@ -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`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user