feature(util) rm rmStrOnce

This commit is contained in:
coderaiser 2014-12-19 09:54:12 -05:00
parent 0f8b224f15
commit 9601355097
6 changed files with 10 additions and 21 deletions

View file

@ -88,14 +88,14 @@ var Util, DOM, CloudFunc, CloudCmd;
case 'js-path-link':
url = CloudCmd.HOST;
href = element.href;
link = Util.rmStr(href, url);
link = href.replace(url, '');
/*
* browser do not replace % -> %25%
* do it for him
*/
link = Util.replaceStr(link, '%%', '%25%');
link = decodeURI(link);
link = Util.rmStrOnce(link, CloudFunc.FS) || '/';
link = link.replace(CloudFunc.FS, '') || '/';
CloudCmd.loadDir({
path : link,
@ -306,7 +306,7 @@ var Util, DOM, CloudFunc, CloudCmd;
Events.add('popstate', function(event) {
var path = event.state;
path = Util.rmStrOnce(path, CloudFunc.FS);
path = path.replace(CloudFunc.FS, '');
if (path)
CloudCmd.loadDir({

View file

@ -145,7 +145,7 @@ var Util, DOM;
num = src.lastIndexOf('/') + 1,
sub = src.substr(src, num),
id = Util.rmStrOnce(src, sub);
id = src.replace(sub, '');
/* убираем точки */
id = id.replace(/\./g, '-');

View file

@ -56,7 +56,7 @@
if (!is) {
next();
} else {
params.name = Util.rmStrOnce(name, apiURL) || '/';
params.name = name.replace(apiURL, '') || '/';
sendData(params, function(error, options, data) {
params.gzip = !error;
@ -264,7 +264,9 @@
if (files.to)
to = mellow.convertPath(files.to);
else
to = Util.rmStrOnce(files.from, ['.zip', '.tar.gz', '.gz']);
['.zip', '.tar.gz', '.gz'].forEach(function(str) {
to = files.from.replace(str);
});
packer.unpack(from, to, function(error) {
var name = path.basename(files.from),

View file

@ -26,7 +26,7 @@
switch(method) {
case 'GET':
name = Util.rmStrOnce(name, '/markdown');
name = name.replace('/markdown', '');
query = ponse.getQuery(request);
if (query === 'relative')

View file

@ -138,7 +138,7 @@
p.name = DIR_HTML + name + '.html';
ponse.sendFile(p);
} else if (isFS) {
name = Util.rmStrOnce(name, CloudFunc.FS) || '/';
name = name.replace(CloudFunc.FS, '') || '/';
path = mellow.convertPath(name);
mellow.read(path, function(error, dir) {

View file

@ -299,19 +299,6 @@
return str;
};
/**
* function remove substring from string one time
* @param str
* @param substr
*/
this.rmStrOnce = function(str, substr) {
var ONCE = true;
str = Util.rmStr(str, substr, ONCE);
return str;
};
/**
* function replase pFrom to pTo in pStr
* @param str