Skip to content

Commit ff15ea1

Browse files
committed
fix(core): avoid extra redirect proxy (#8252)
1 parent d2cb7b7 commit ff15ea1

File tree

1 file changed

+12
-2
lines changed
  • packages/frontend/core/src/utils

1 file changed

+12
-2
lines changed
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
export function popupWindow(target: string) {
2-
const url = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
32
target = /^https?:\/\//.test(target)
43
? target
54
: BUILD_CONFIG.serverUrlPrefix + target;
6-
url.searchParams.set('redirect_uri', target);
5+
const targetUrl = new URL(target);
6+
7+
let url: string;
8+
// safe to open directly if in the same origin
9+
if (targetUrl.origin === location.origin) {
10+
url = target;
11+
} else {
12+
const builder = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
13+
builder.searchParams.set('redirect_uri', target);
14+
url = builder.toString();
15+
}
16+
717
return window.open(url, '_blank', `noreferrer noopener`);
818
}

0 commit comments

Comments
 (0)