mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +00:00
Add Regexp possibility to titleReplace
Check if the given needle is a regexp, if so create one and use it instead
This commit is contained in:
parent
a4cb53fdb4
commit
49fb9108e9
@ -379,6 +379,13 @@ Module.register("calendar", {
|
||||
titleTransform: function (title) {
|
||||
for (var needle in this.config.titleReplace) {
|
||||
var replacement = this.config.titleReplace[needle];
|
||||
|
||||
var regParts = needle.match(/^\/(.+)\/([gim]*)$/);
|
||||
if (regParts) {
|
||||
// the parsed pattern is a regexp.
|
||||
needle = new RegExp(regParts[1], regParts[2]);
|
||||
}
|
||||
|
||||
title = title.replace(needle, replacement);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user