mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(core): avoid using serverUrlPrefix config (#8448)
This commit is contained in:
@@ -3,20 +3,31 @@ import { apis } from '@affine/electron-api';
|
||||
|
||||
const logger = new DebugLogger('popup');
|
||||
|
||||
const origin = BUILD_CONFIG.isElectron
|
||||
? BUILD_CONFIG.serverUrlPrefix
|
||||
: location.origin;
|
||||
|
||||
/**
|
||||
* @deprecated need to be refactored as [UrlService] dependencies on [ServerConfigService]
|
||||
*/
|
||||
export function popupWindow(target: string) {
|
||||
target = /^https?:\/\//.test(target)
|
||||
? target
|
||||
: BUILD_CONFIG.serverUrlPrefix + target;
|
||||
const isFullUrl = /^https?:\/\//.test(target);
|
||||
|
||||
const redirectProxy = origin + '/redirect-proxy';
|
||||
target = isFullUrl ? target : origin + target;
|
||||
|
||||
const targetUrl = new URL(target);
|
||||
|
||||
let url: string;
|
||||
// safe to open directly if in the same origin
|
||||
if (targetUrl.origin === location.origin) {
|
||||
if (targetUrl.origin === origin) {
|
||||
url = target;
|
||||
} else {
|
||||
const builder = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
|
||||
builder.searchParams.set('redirect_uri', target);
|
||||
url = builder.toString();
|
||||
const search = new URLSearchParams({
|
||||
redirect_uri: target,
|
||||
});
|
||||
|
||||
url = `${redirectProxy}?${search.toString()}`;
|
||||
}
|
||||
|
||||
if (BUILD_CONFIG.isElectron) {
|
||||
|
||||
Reference in New Issue
Block a user