mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
refactor(main) getPathName: add querystring
This commit is contained in:
parent
6281248304
commit
ae845a8b05
4 changed files with 20 additions and 24 deletions
|
|
@ -104,13 +104,6 @@
|
|||
AppCache.createManifest();
|
||||
}
|
||||
|
||||
/**
|
||||
* rest interface
|
||||
* @pParams pConnectionData {request, responce}
|
||||
*/
|
||||
function rest(pConnectionData) {
|
||||
return Util.exec(main.rest, pConnectionData);
|
||||
}
|
||||
|
||||
function init() {
|
||||
var lServerDir, lArg, lParams, lFiles;
|
||||
|
|
@ -152,7 +145,7 @@
|
|||
|
||||
lParams = {
|
||||
appcache : appCacheProcessing,
|
||||
rest : rest,
|
||||
rest : main.rest,
|
||||
route : route
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -169,9 +169,6 @@
|
|||
lQuery = lParsedUrl.search || '',
|
||||
path = main.getPathName(pReq);
|
||||
|
||||
/* added supporting of Russian language in directory names */
|
||||
path = Querystring.unescape(path);
|
||||
|
||||
if (!expressApp)
|
||||
Util.log(pReq.method + ' ' + path + lQuery);
|
||||
|
||||
|
|
@ -182,7 +179,7 @@
|
|||
};
|
||||
|
||||
if (lConfig.rest)
|
||||
lRet = Util.exec(Rest, data);
|
||||
lRet = Util.exec(Rest, pReq, pRes);
|
||||
|
||||
if (!lRet && Route)
|
||||
lRet = Util.exec(Route, data);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
SLASH,
|
||||
ISWIN32,
|
||||
ext,
|
||||
path, fs, zlib, url, pipe, CloudFunc, diffPatch,
|
||||
path, fs, zlib, url, pipe, CloudFunc, diffPatch, querystring,
|
||||
|
||||
OK, FILE_NOT_FOUND, MOVED_PERMANENTLY,
|
||||
REQUEST, RESPONSE,
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
exports.https = require('https'),
|
||||
exports.path = path = require('path'),
|
||||
exports.url = url = require('url'),
|
||||
exports.querystring = require('querystring'),
|
||||
exports.querystring = querystring = require('querystring'),
|
||||
|
||||
/* Constants */
|
||||
/* current dir + 2 levels up */
|
||||
|
|
@ -425,8 +425,10 @@
|
|||
var pathname, parsed;
|
||||
|
||||
if (req) {
|
||||
parsed = url.parse(req.url);
|
||||
pathname = parsed.pathname;
|
||||
parsed = url.parse(req.url);
|
||||
pathname = parsed.pathname;
|
||||
/* supporting of Russian language in directory names */
|
||||
pathname = querystring.unescape(pathname);
|
||||
}
|
||||
|
||||
return pathname;
|
||||
|
|
|
|||
|
|
@ -37,17 +37,21 @@
|
|||
* rest interface
|
||||
* @pParams {request, responce}
|
||||
*/
|
||||
exports.api = function(pParams) {
|
||||
var ret = main.checkParams(pParams);
|
||||
exports.api = function(request, response) {
|
||||
var apiURL, name, ret;
|
||||
|
||||
if (ret) {
|
||||
var lAPIURL = main.config.apiURL,
|
||||
p = pParams;
|
||||
if (request && response) {
|
||||
apiURL = main.config.apiURL;
|
||||
name = main.getPathName(request);
|
||||
ret = Util.isContainStr(name, apiURL);
|
||||
|
||||
ret = Util.isContainStr(p.name, lAPIURL);
|
||||
if (ret) {
|
||||
p.name = Util.removeStrOneTime(p.name, lAPIURL) || '/';
|
||||
sendData(pParams);
|
||||
name = Util.removeStrOneTime(name, apiURL) || '/';
|
||||
sendData({
|
||||
request : request,
|
||||
response : response,
|
||||
name : name
|
||||
});
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue