Skip to content

Commit 70f284d

Browse files
authored
Fix use-domain hook logic to not include any paths on domain (#2309)
* update use domain hook logic * Add protocol
1 parent ccae204 commit 70f284d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/shell/hooks/use-domain.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ export const useDomain: UseDomain = () => {
1212
const { domains }: { domains: Domain[] } = state.instance;
1313

1414
// Let WebEngine figure out https & www settings
15-
const format = (domain: string) => `http://${domain}`;
15+
const format = (domain: string): string => {
16+
try {
17+
const url = new URL(domain.includes("://") ? domain : `http://${domain}`);
18+
return `http://${url.hostname}`;
19+
} catch (error) {
20+
return `http://${domain}`; // fallback to the original input with http:// in case of error
21+
}
22+
};
1623

1724
if (Array.isArray(domains) && domains.length) {
1825
/**

0 commit comments

Comments
 (0)