fix: fix url which without protocol will not been correct parse

pull/90/head
moonrailgun 2 years ago
parent 178acf5903
commit cfd1479ac6

@ -4,6 +4,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"script_sanitize": "^1.2.6"
"script_sanitize": "^1.2.6",
"url-regex": "^5.0.0"
}
}

@ -1,6 +1,7 @@
import React from 'react';
import { Translate } from '../translate';
import { WebviewKeepAlive } from '@capital/component';
import urlRegex from 'url-regex';
const GroupWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
const panelInfo = props.panelInfo;
@ -9,7 +10,14 @@ const GroupWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
return <div>{Translate.notfound}</div>;
}
const url = panelInfo?.meta?.url;
let url = String(panelInfo?.meta?.url);
if (
!url.includes('://') &&
urlRegex({ exact: true, strict: false }).test(url)
) {
// 不包含协议, 但是是个网址
url = 'https://' + url;
}
return (
<WebviewKeepAlive key={String(url)} className="w-full h-full" url={url} />

@ -829,8 +829,10 @@ importers:
client/web/plugins/com.msgbyte.webview:
specifiers:
script_sanitize: ^1.2.6
url-regex: ^5.0.0
dependencies:
script_sanitize: 1.2.6
url-regex: 5.0.0
client/web/plugins/com.msgbyte.wenshushu:
specifiers:
@ -844,6 +846,9 @@ importers:
devDependencies:
react: 18.2.0
packages/types:
specifiers: {}
server:
specifiers:
'@babel/helper-compilation-targets': ^7.18.2

Loading…
Cancel
Save