浏览代码

sort rules

Gildas 7 年之前
父节点
当前提交
46e89e8218
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      extension/core/bg/config.js

+ 1 - 1
extension/core/bg/config.js

@@ -209,7 +209,7 @@ singlefile.config = (() => {
 		},
 		async getOptions(profileName, url, autoSave) {
 			const config = await getConfig();
-			const urlRule = config.rules.find(rule => url && url.includes(rule.url));
+			const urlRule = config.rules.sort((ruleLeft, ruleRight) => ruleRight.url.length - ruleLeft.url.length).find(rule => url && url.includes(rule.url));
 			return urlRule ? config.profiles[urlRule[autoSave ? "autoSaveProfile" : "profile"]] : config.profiles[profileName || singlefile.config.DEFAULT_PROFILE_NAME];
 		},
 		async updateProfile(profileName, profile) {