Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit a77d137

Browse files
committed
fix: Crash issue because invalid custom external script injection
1 parent 07bdcca commit a77d137

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/js/run.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import { getHosts, getHostKey, findMatchedHosts } from 'libs'
33

44
const baseURL = chrome.runtime.getURL('base.js')
55

6+
const isValidURL = (url) => {
7+
return (
8+
url &&
9+
(url.startsWith('//') ||
10+
url.startsWith('https://') ||
11+
url.startsWith('http://'))
12+
)
13+
}
14+
615
const catchErr = (e) => {
716
console.error('Failed to inject scripts:', e)
817
}
@@ -44,7 +53,7 @@ const extractScripts = (customjs, injections) => {
4453
.split(';')
4554
.map((x) => x.trim())
4655
.forEach((line) => {
47-
if (line) {
56+
if (isValidURL(line)) {
4857
injections.add(line)
4958
}
5059
})

0 commit comments

Comments
 (0)