Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/pages/install/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@

useEffect(() => {
!loaded && initAsync();
}, [searchParams, loaded]);

Check warning on line 334 in src/pages/install/App.tsx

View workflow job for this annotation

GitHub Actions / Run tests

React Hook useEffect has a missing dependency: 'initAsync'. Either include it or remove the dependency array

const [watchFile, setWatchFile] = useState(false);
const metadataLive = useMemo(() => (scriptInfo?.metadata || {}) as SCMetadata, [scriptInfo]);
Expand Down Expand Up @@ -646,31 +646,29 @@
return () => {
unmountFileTrack(handle);
};
}, [memoWatchFile]);

Check warning on line 649 in src/pages/install/App.tsx

View workflow job for this annotation

GitHub Actions / Run tests

React Hook useEffect has missing dependencies: 'localFileHandle', 'scriptInfo?.uuid', 'setupWatchFile', and 'watchFile'. Either include them or remove the dependency array

// 检查是否有 uuid 或 file
const searchParamUrl = searchParams.get("url");
const hasValidSourceParam = !searchParamUrl && !!(searchParams.get("uuid") || searchParams.get("file"));

const urlHref = useMemo(() => {
if (!hasValidSourceParam) {
let rawUrl;
if (searchParamUrl) {
try {
// 取url=之后的所有内容
rawUrl = location.search.match(/\?url=([^&]+)/)?.[1] || "";
if (rawUrl) {
const urlObject = new URL(rawUrl);
// 验证解析后的 URL 是否具备核心要素,确保安全性与合法性
if (urlObject.protocol && urlObject.hostname && urlObject.pathname) {
return rawUrl;
}
const idx = location.search.indexOf("url=");
const rawUrl = idx !== -1 ? location.search.slice(idx + 4) : searchParamUrl;
const urlObject = new URL(rawUrl);
// 验证解析后的 URL 是否具备核心要素,确保安全性与合法性
if (urlObject.protocol && urlObject.hostname && urlObject.pathname) {
return rawUrl;
}
} catch {
// ignored
}
}
return "";
}, [hasValidSourceParam]);
}, [searchParamUrl]);

const [fetchingState, setFetchingState] = useState({
loadingStatus: "",
Expand Down
Loading