Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

forehaloff15ea1eec4d
diff --git a/packages/frontend/core/src/utils/popup.ts b/packages/frontend/core/src/utils/popup.ts
index 811a7f3444..528d629e33 100644
--- a/packages/frontend/core/src/utils/popup.ts
+++ b/packages/frontend/core/src/utils/popup.ts
@@ -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`);
}