mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(util) add getRegExp [from wild card]
This commit is contained in:
parent
7cf9fad27e
commit
c78a357d96
2 changed files with 21 additions and 9 deletions
|
|
@ -958,15 +958,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
if (type !== null) {
|
||||
SelectType = type;
|
||||
|
||||
/* if type empty - select all files */
|
||||
if (type === '')
|
||||
type = '*';
|
||||
|
||||
type = '^' + type; /* search from start of line */
|
||||
type = Util.replaceStr(type, '.', '\\.');
|
||||
type = Util.replaceStr(type, '*', '.*');
|
||||
type = Util.replaceStr(type, '?', '.?\\');
|
||||
type += '$'; /* search to end of line */
|
||||
type = Util.getRegExp(type);
|
||||
|
||||
n = files && files.length;
|
||||
for (i = 0; i < n; i++) {
|
||||
|
|
|
|||
20
lib/util.js
20
lib/util.js
|
|
@ -559,6 +559,26 @@
|
|||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* get regexp from wild card
|
||||
*/
|
||||
this.getRegExp = function(wildcard) {
|
||||
var regExp;
|
||||
|
||||
if (!wildcard)
|
||||
wildcard = '*';
|
||||
|
||||
wildcard = '^' + wildcard; /* search from start of line */
|
||||
wildcard = Util.replaceStr(wildcard, '.', '\\.');
|
||||
wildcard = Util.replaceStr(wildcard, '*', '.*');
|
||||
wildcard = Util.replaceStr(wildcard, '?', '.?\\');
|
||||
wildcard += '$'; /* search to end of line */
|
||||
|
||||
regExp = new RegExp(wildcard);
|
||||
|
||||
return regExp;
|
||||
};
|
||||
|
||||
/**
|
||||
* function render template with view
|
||||
* @templ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue