(obj, flag)
| 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; |
no test coverage detected