mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
wash meta.url through url search (#795)
This commit is contained in:
parent
047513bf3a
commit
65c446e4a1
@ -253,22 +253,6 @@ export class WebViewModel implements ViewModel {
|
|||||||
return searchTemplate.replace("{query}", encodeURIComponent(url));
|
return searchTemplate.replace("{query}", encodeURIComponent(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
normalizeUrl(url: string) {
|
|
||||||
if (!url) {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const parsedUrl = new URL(url);
|
|
||||||
if (parsedUrl.hostname.startsWith("www.")) {
|
|
||||||
parsedUrl.hostname = parsedUrl.hostname.slice(4);
|
|
||||||
}
|
|
||||||
return parsedUrl.href;
|
|
||||||
} catch (e) {
|
|
||||||
return url.replace(/\/+$/, "") + "/";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a new URL in the webview.
|
* Load a new URL in the webview.
|
||||||
* @param newUrl The new URL to load in the webview.
|
* @param newUrl The new URL to load in the webview.
|
||||||
@ -390,7 +374,10 @@ const WebView = memo(({ model }: WebViewProps) => {
|
|||||||
const blockData = jotai.useAtomValue(model.blockAtom);
|
const blockData = jotai.useAtomValue(model.blockAtom);
|
||||||
const defaultUrlAtom = useSettingsKeyAtom("web:defaulturl");
|
const defaultUrlAtom = useSettingsKeyAtom("web:defaulturl");
|
||||||
const defaultUrl = jotai.useAtomValue(defaultUrlAtom);
|
const defaultUrl = jotai.useAtomValue(defaultUrlAtom);
|
||||||
const metaUrl = blockData?.meta?.url || defaultUrl;
|
const defaultSearchAtom = useSettingsKeyAtom("web:defaultsearch");
|
||||||
|
const defaultSearch = jotai.useAtomValue(defaultSearchAtom);
|
||||||
|
let metaUrl = blockData?.meta?.url || defaultUrl;
|
||||||
|
metaUrl = model.ensureUrlScheme(metaUrl, defaultSearch);
|
||||||
const metaUrlRef = React.useRef(metaUrl);
|
const metaUrlRef = React.useRef(metaUrl);
|
||||||
|
|
||||||
// The initial value of the block metadata URL when the component first renders. Used to set the starting src value for the webview.
|
// The initial value of the block metadata URL when the component first renders. Used to set the starting src value for the webview.
|
||||||
|
Loading…
Reference in New Issue
Block a user