Skip to content

Commit 2855a38

Browse files
committed
#488 added "/" support to supply own regex switches
1 parent abee831 commit 2855a38

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "Axel Grude",
1111
"name" : "QuickFolders",
1212
"description" : "__MSG_extensionDescription__",
13-
"version" : "6.8pre48",
13+
"version" : "6.8",
1414
"default_locale": "en",
1515
"developer" : {
1616
"name" : "Axel Grude",

qf-background.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,31 @@ async function filterMailsRegex(searchOptions, tabId = null) {
133133
const group = searchOptions.group; // 0 for full match
134134
const searchSelected = searchOptions.searchSelected;
135135
const searchCriteria = searchOptions.searchCriteria; // if fields is null, do not change this!
136-
let pattern = searchOptions.pattern; // allow overwriting in debugger for test!
137-
const isEmpty = (!pattern); // non empty search string, reset!
136+
let searchValue = searchOptions.pattern, // allow overwriting in debugger for test!
137+
searchFlags = "";
138138
const behavior = searchOptions.behavior || DEFAULT_BEHAVIOR;
139139

140+
if (searchValue.charAt(0) == "/") {
141+
let endIdx = searchValue.lastIndexOf("/");
142+
if (endIdx) { // must be>0! otherwise 2nd slash is missing!!
143+
searchValue = searchOptions.pattern.substring(1, endIdx);
144+
searchFlags = searchOptions.pattern.substring(endIdx + 1);
145+
} else {
146+
const isDebug = await messenger.LegacyPrefs.getPref(legacyPrefPath("debug"));
147+
if (isDebug){
148+
console.log(`Invalid search string in find Related - missing 2nd '/' : ${searchFlags}`);
149+
}
150+
searchFlags = searchOptions.pattern.substring(1); // removing beginning '/'
151+
}
152+
}
153+
154+
if (!searchFlags) {
155+
searchFlags = "gm";
156+
}
140157

141-
const regex = new RegExp(pattern, "gm");
158+
const regex = new RegExp(searchValue, searchFlags);
142159
let results, searchVal = "";
143160

144-
if (isEmpty) {
145-
// reset search!
146-
}
147-
148161
// context.extension.tabManager.getWrapper(tabInfo).id
149162
if (!tabId) {
150163
const currentTab = await messenger.tabs.getCurrent();

0 commit comments

Comments
 (0)