Skip to content

Commit

Permalink
🐛 修复http* match问题 #132
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jan 11, 2023
1 parent f0c3853 commit b17581b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ const chromeManifest = { ...manifest };
delete chromeManifest.content_security_policy;

delete firefoxManifest.sandbox;
firefoxManifest.content_security_policy =
"script-src 'self' blob:; object-src 'self' blob:";
// firefoxManifest.content_security_policy =
// "script-src 'self' blob:; object-src 'self' blob:";
firefoxManifest.browser_specific_settings = {
gecko: { strict_min_version: "91.1.0" },
};
Expand Down
1 change: 0 additions & 1 deletion src/app/service/system/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export class SystemManager extends Manager {
"",
uuidv5(data.data.uri, uuidv5.URL)
);
console.log(script);
this.scriptManager.event.upsertHandler(script, "vscode");
break;
}
Expand Down
3 changes: 1 addition & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@
],
"sandbox": {
"pages": ["src/sandbox.html"]
},
"content_security_policy": "script-src 'self' blob:; object-src 'self' blob:"
}
}
17 changes: 13 additions & 4 deletions src/pkg/utils/match.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,17 @@ describe("特殊情况", () => {
expect(url.match("http://www.example.com/")).toEqual(["ok1"]);
});

it("prefix *",()=>{
const url=new UrlMatch<string>();
url.add("*https://www.baidu.com*","ok1");
it("prefix *", () => {
const url = new UrlMatch<string>();
url.add("*https://www.baidu.com*", "ok1");
expect(url.match("https://www.baidu.com")).toEqual(["ok1"]);
})
});
it("http*", () => {
const url = new UrlMatch<string>();
url.add("http*://example.com/*", "ok1");
expect(url.match("https://example.com/")).toEqual(["ok1"]);
expect(url.match("http://example.com/")).toEqual(["ok1"]);
});
});

// --- include
Expand Down Expand Up @@ -245,6 +251,9 @@ describe("UrlInclude-2", () => {
)
).toEqual(["ok1", "ok2"]);
expect(url.match("https://github.com/CodFrm")).toEqual(["ok1", "ok2"]);
url.add("http*://example.com/*", "ok3");
expect(url.match("https://example.com/")).toEqual(["ok1", "ok2", "ok3"]);
expect(url.match("http://example.com/")).toEqual(["ok1", "ok2", "ok3"]);
});
it("port", () => {
const url = new UrlInclude<string>();
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/utils/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Match<T> {
u.scheme = ".+?";
break;
case "http*":
u.scheme = "http[s]";
u.scheme = "http[s]?";
break;
default:
}
Expand Down Expand Up @@ -236,7 +236,7 @@ export class UrlInclude<T> extends UrlMatch<T> {
u.scheme = ".+?";
break;
case "http*":
u.scheme = "http[s]";
u.scheme = "http[s]?";
break;
default:
}
Expand Down

0 comments on commit b17581b

Please sign in to comment.