Skip to content

Commit

Permalink
fix get 'script-link'
Browse files Browse the repository at this point in the history
  • Loading branch information
wqcstrong committed Dec 6, 2023
1 parent a61cf06 commit 010c352
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface TCreateRoom {

const parseSchemeWithScript = () => {
try {
const { protocol } = new URL(document.currentScript?.getAttribute('src')!);
const { protocol } = new URL(Config.scriptLink);
if (protocol.startsWith('https')) {
return ['https://', 'wss://'];
}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { InitConfig } from 'types';

const scriptLink = (document.currentScript as HTMLScriptElement)?.src;

export class Config {
private static value: Required<InitConfig>;

public static scriptLink = (document.currentScript as HTMLScriptElement)?.src;

private static resolveConfig: () => Required<InitConfig> = () => {
const defaultConfig = {
api: '',
Expand All @@ -14,11 +14,11 @@ export class Config {
title: '',
enableSSL: null,
};
if (!scriptLink) {
if (!Config.scriptLink) {
return defaultConfig;
}

const { host, origin } = new URL(scriptLink);
const { host, origin } = new URL(Config.scriptLink);
const result = {
...defaultConfig,
api: host,
Expand Down

0 comments on commit 010c352

Please sign in to comment.