mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(util) rm rmStrOnce
This commit is contained in:
parent
0f8b224f15
commit
9601355097
6 changed files with 10 additions and 21 deletions
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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, '-');
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
switch(method) {
|
||||
case 'GET':
|
||||
name = Util.rmStrOnce(name, '/markdown');
|
||||
name = name.replace('/markdown', '');
|
||||
query = ponse.getQuery(request);
|
||||
|
||||
if (query === 'relative')
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
13
lib/util.js
13
lib/util.js
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue