forked from Shinonome/dots-hyprland
search: add prefix for app search
This commit is contained in:
@@ -257,4 +257,32 @@ Singleton {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given prefix from the string if present.
|
||||
* @param { string } str
|
||||
* @param { string } prefix
|
||||
* @returns { string }
|
||||
*/
|
||||
function cleanPrefix(str, prefix) {
|
||||
if (str.startsWith(prefix)) {
|
||||
return str.slice(prefix.length);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first matching prefix from the string if present.
|
||||
* @param { string } str
|
||||
* @param { string[] } prefixes
|
||||
* @returns { string }
|
||||
*/
|
||||
function cleanOnePrefix(str, prefixes) {
|
||||
for (let i = 0; i < prefixes.length; ++i) {
|
||||
if (str.startsWith(prefixes[i])) {
|
||||
return str.slice(prefixes[i].length);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user