MCPcopy Create free account
hub / github.com/hoothin/UserScripts / toRE

Function toRE

Picviewer CE+/dist.user.js:13495–13510  ·  view source on GitHub ↗
(obj, flag)

Source from the content-addressed store, hash-verified

13493 }
13494
13495 function toRE(obj, flag) {
13496 if (!obj) {
13497 return obj;
13498 } else if (obj instanceof RegExp) {
13499 return obj;
13500 } else if (flag) {
13501 return new RegExp(obj, flag);
13502 } else if (obj instanceof Array) {
13503 return new RegExp(obj[0], obj[1]);
13504 } else if (typeof obj === 'string') {
13505 if (obj.indexOf('*') != -1 && obj.indexOf('.*') == -1) {
13506 obj = wildcardToRegExpStr(obj);
13507 }
13508 return new RegExp(obj);
13509 }
13510 }
13511
13512 function wildcardToRegExpStr(urlstr) {
13513 if (urlstr.source) return urlstr.source;

Callers 2

searchByTimeFunction · 0.70
initFunction · 0.70

Calls 1

wildcardToRegExpStrFunction · 0.70

Tested by

no test coverage detected