fix: Remove hardcoded domains
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import { Separator } from '$/components/ui/separator';
|
||||
import * as ToggleGroup from '$/components/ui/toggle-group';
|
||||
import { TID } from '$/constants';
|
||||
import { env } from '$/util/env';
|
||||
import { getDomain } from '$/util/util';
|
||||
import { browser } from '$app/environment';
|
||||
import { waitForRender } from '$lib/util/autoSync';
|
||||
import { inputStateStore, stateStore, urlsStore } from '$lib/util/state';
|
||||
@@ -205,7 +205,10 @@ ${svgString}`);
|
||||
<DownloadIcon />
|
||||
{text}
|
||||
</Button>
|
||||
<ExternalLinkWrapper labelPrefix="Opens your diagram in" domain="mermaid.ink" isVisible={!!url}>
|
||||
<ExternalLinkWrapper
|
||||
labelPrefix="Opens your diagram in"
|
||||
domain={getDomain(url)}
|
||||
isVisible={!!url}>
|
||||
<Button class="rounded-l-none" href={url} target="_blank" rel="noreferrer noopener">
|
||||
<ExternalLinkIcon />
|
||||
</Button>
|
||||
@@ -238,8 +241,8 @@ ${svgString}`);
|
||||
{@render dualActionButton('SVG', onDownloadSVG, $urlsStore.svg)}
|
||||
<ExternalLinkWrapper
|
||||
labelPrefix="Opens your diagram in"
|
||||
domain="Kroki.io"
|
||||
isVisible={!!env.krokiRendererUrl}>
|
||||
domain={getDomain($urlsStore.kroki)}
|
||||
isVisible={!!$urlsStore.kroki}>
|
||||
<a target="_blank" rel="noreferrer" class="flex-grow" href={$urlsStore.kroki}>
|
||||
<Button class="action-btn flex w-full items-center gap-2">
|
||||
<ExternalLinkIcon /> Kroki
|
||||
@@ -253,7 +256,7 @@ ${svgString}`);
|
||||
{/if}
|
||||
<ExternalLinkWrapper
|
||||
labelPrefix="Thumbnail generated by"
|
||||
domain="mermaid.ink"
|
||||
domain={getDomain($urlsStore.png)}
|
||||
isVisible={!!$urlsStore.mdCode}>
|
||||
<CopyInput value={$urlsStore.mdCode} label="Copy Markdown" testID={TID.copyMarkdown} />
|
||||
</ExternalLinkWrapper>
|
||||
|
||||
@@ -5,6 +5,12 @@ import { applyMigrations } from './migrations';
|
||||
import { initURLSubscription, loadState, updateCodeStore, verifyState } from './state';
|
||||
import { initAnalytics, plausible } from './stats';
|
||||
|
||||
export const getDomain = (url?: string): string => {
|
||||
if (!url) return '';
|
||||
const domain = new URL(url).hostname;
|
||||
return domain;
|
||||
};
|
||||
|
||||
export const loadStateFromURL = (): void => {
|
||||
loadState(window.location.hash.slice(1));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user