mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 10:38:26 +00:00
feature(util) rm replaceStr
This commit is contained in:
parent
a1daf8e884
commit
c33435b692
3 changed files with 7 additions and 28 deletions
|
|
@ -93,7 +93,7 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
* browser do not replace % -> %25%
|
||||
* do it for him
|
||||
*/
|
||||
link = Util.replaceStr(link, '%%', '%25%');
|
||||
link = link.replace('%%', '%25%');
|
||||
link = decodeURI(link);
|
||||
link = link.replace(CloudFunc.FS, '') || '/';
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
* if we send ajax request -
|
||||
* no need in hash so we escape #
|
||||
*/
|
||||
p.url = Util.replaceStr(p.url, '#', '%23');
|
||||
p.url = p.url.replace('#', '%23');
|
||||
|
||||
DOM.load.ajax({
|
||||
method : p.method,
|
||||
|
|
|
|||
31
lib/util.js
31
lib/util.js
|
|
@ -220,28 +220,6 @@
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* function replase pFrom to pTo in pStr
|
||||
* @param str
|
||||
* @param from
|
||||
* @param to
|
||||
* @param notEscape
|
||||
*/
|
||||
this.replaceStr = function(str, from, to, notEscape) {
|
||||
var regExp,
|
||||
isStr = Util.type.string(str);
|
||||
|
||||
if (isStr && from) {
|
||||
if (!notEscape)
|
||||
from = Util.escapeRegExp(from);
|
||||
|
||||
regExp = new RegExp(from, 'g');
|
||||
str = str.replace(regExp, to);
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
this.escapeRegExp = function(str) {
|
||||
var isStr = Util.type.string(str);
|
||||
|
||||
|
|
@ -260,10 +238,11 @@
|
|||
if (!wildcard)
|
||||
wildcard = '*';
|
||||
|
||||
wildcard = '^' + wildcard; /* search from start of line */
|
||||
wildcard = Util.replaceStr(wildcard, '.', '\\.');
|
||||
wildcard = Util.replaceStr(wildcard, '*', '.*');
|
||||
wildcard = Util.replaceStr(wildcard, '?', '.?\\');
|
||||
wildcard = '^' + wildcard /* search from start of line */
|
||||
.replace('.', '\\.')
|
||||
.replace('*', '.*')
|
||||
.replace('?', '.?\\');
|
||||
|
||||
wildcard += '$'; /* search to end of line */
|
||||
|
||||
regExp = new RegExp(wildcard);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue