Skip to content

Commit

Permalink
fix(core): 优化核心域名匹配逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Oct 20, 2023
1 parent 10364c9 commit 8cbcc94
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/core/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ export const $ = {
for (const key in project.scripts) {
if (Object.prototype.hasOwnProperty.call(project.scripts, key)) {
const script = project.scripts[key];
// 被排除的网页
if (script.excludes?.some((u) => urls.some((url) => RegExp(u[1]).test(url)))) {
continue;
}

if (script.url.some((u) => urls.some((url) => RegExp(u[1]).test(url)))) {
scripts.push(script);
// 平台域名是否匹配
if (
project.domains.length === 0 ||
project.domains.some((d) => urls.some((url) => new URL(url).origin.includes(d)))
) {
// 被排除的网页
if (script.excludes?.some((u) => urls.some((url) => RegExp(u[1]).test(url)))) {
continue;
}

if (script.url.some((u) => urls.some((url) => RegExp(u[1]).test(url)))) {
scripts.push(script);
}
}
}
}
Expand Down

0 comments on commit 8cbcc94

Please sign in to comment.