Skip to content

Commit b17581b

Browse files
committed
🐛 修复http* match问题 #132
1 parent f0c3853 commit b17581b

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

build/pack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const chromeManifest = { ...manifest };
6161
delete chromeManifest.content_security_policy;
6262

6363
delete firefoxManifest.sandbox;
64-
firefoxManifest.content_security_policy =
65-
"script-src 'self' blob:; object-src 'self' blob:";
64+
// firefoxManifest.content_security_policy =
65+
// "script-src 'self' blob:; object-src 'self' blob:";
6666
firefoxManifest.browser_specific_settings = {
6767
gecko: { strict_min_version: "91.1.0" },
6868
};

src/app/service/system/manager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ export class SystemManager extends Manager {
150150
"",
151151
uuidv5(data.data.uri, uuidv5.URL)
152152
);
153-
console.log(script);
154153
this.scriptManager.event.upsertHandler(script, "vscode");
155154
break;
156155
}

src/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@
4141
],
4242
"sandbox": {
4343
"pages": ["src/sandbox.html"]
44-
},
45-
"content_security_policy": "script-src 'self' blob:; object-src 'self' blob:"
44+
}
4645
}

src/pkg/utils/match.test.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,17 @@ describe("特殊情况", () => {
142142
expect(url.match("http://www.example.com/")).toEqual(["ok1"]);
143143
});
144144

145-
it("prefix *",()=>{
146-
const url=new UrlMatch<string>();
147-
url.add("*https://www.baidu.com*","ok1");
145+
it("prefix *", () => {
146+
const url = new UrlMatch<string>();
147+
url.add("*https://www.baidu.com*", "ok1");
148148
expect(url.match("https://www.baidu.com")).toEqual(["ok1"]);
149-
})
149+
});
150+
it("http*", () => {
151+
const url = new UrlMatch<string>();
152+
url.add("http*://example.com/*", "ok1");
153+
expect(url.match("https://example.com/")).toEqual(["ok1"]);
154+
expect(url.match("http://example.com/")).toEqual(["ok1"]);
155+
});
150156
});
151157

152158
// --- include
@@ -245,6 +251,9 @@ describe("UrlInclude-2", () => {
245251
)
246252
).toEqual(["ok1", "ok2"]);
247253
expect(url.match("https://github.com/CodFrm")).toEqual(["ok1", "ok2"]);
254+
url.add("http*://example.com/*", "ok3");
255+
expect(url.match("https://example.com/")).toEqual(["ok1", "ok2", "ok3"]);
256+
expect(url.match("http://example.com/")).toEqual(["ok1", "ok2", "ok3"]);
248257
});
249258
it("port", () => {
250259
const url = new UrlInclude<string>();

src/pkg/utils/match.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class Match<T> {
4444
u.scheme = ".+?";
4545
break;
4646
case "http*":
47-
u.scheme = "http[s]";
47+
u.scheme = "http[s]?";
4848
break;
4949
default:
5050
}
@@ -236,7 +236,7 @@ export class UrlInclude<T> extends UrlMatch<T> {
236236
u.scheme = ".+?";
237237
break;
238238
case "http*":
239-
u.scheme = "http[s]";
239+
u.scheme = "http[s]?";
240240
break;
241241
default:
242242
}

0 commit comments

Comments
 (0)