Enhancements

Add support for specifying node rename pattern in URL argument.
Optimize codes.
This commit is contained in:
Tindy X 2020-05-05 22:40:32 +08:00
parent af7d7fae05
commit 40d3b36f92
No known key found for this signature in database
GPG Key ID: C6AD413169968D58
3 changed files with 10 additions and 4 deletions

View File

@ -1131,6 +1131,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
std::string include = UrlDecode(getUrlArg(argument, "include")), exclude = UrlDecode(getUrlArg(argument, "exclude")); std::string include = UrlDecode(getUrlArg(argument, "include")), exclude = UrlDecode(getUrlArg(argument, "exclude"));
std::string groups = urlsafe_base64_decode(getUrlArg(argument, "groups")), ruleset = urlsafe_base64_decode(getUrlArg(argument, "ruleset")), config = UrlDecode(getUrlArg(argument, "config")); std::string groups = urlsafe_base64_decode(getUrlArg(argument, "groups")), ruleset = urlsafe_base64_decode(getUrlArg(argument, "ruleset")), config = UrlDecode(getUrlArg(argument, "config"));
std::string dev_id = getUrlArg(argument, "dev_id"), filename = getUrlArg(argument, "filename"), interval_str = getUrlArg(argument, "interval"), strict_str = getUrlArg(argument, "strict"); std::string dev_id = getUrlArg(argument, "dev_id"), filename = getUrlArg(argument, "filename"), interval_str = getUrlArg(argument, "interval"), strict_str = getUrlArg(argument, "strict");
std::string ext_rename = UrlDecode(getUrlArg(argument, "rename"));
/// switches with default value /// switches with default value
tribool upload = getUrlArg(argument, "upload"), emoji = getUrlArg(argument, "emoji"); tribool upload = getUrlArg(argument, "upload"), emoji = getUrlArg(argument, "emoji");
@ -1188,7 +1189,10 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
std::string proxy = parseProxy(proxy_subscription); std::string proxy = parseProxy(proxy_subscription);
ext.emoji_array = safe_get_emojis(); ext.emoji_array = safe_get_emojis();
ext.rename_array = safe_get_renames(); if(ext_rename.size())
ext.rename_array = split(ext_rename, "`");
else
ext.rename_array = safe_get_renames();
//check other flags //check other flags
if(!emoji.is_undef()) if(!emoji.is_undef())

View File

@ -2125,14 +2125,16 @@ static inline unsigned long long streamToInt(const std::string &stream)
return 0; return 0;
double streamval = 1.0; double streamval = 1.0;
std::vector<std::string> units = {"B", "KB", "MB", "GB", "TB", "PB", "EB"}; std::vector<std::string> units = {"B", "KB", "MB", "GB", "TB", "PB", "EB"};
for(size_t index = units.size() - 1; index >= 0; index--) size_t index = units.size();
do
{ {
index--;
if(endsWith(stream, units[index])) if(endsWith(stream, units[index]))
{ {
streamval = std::pow(1024, index) * to_number<float>(stream.substr(0, stream.size() - units[index].size()), 0.0); streamval = std::pow(1024, index) * to_number<float>(stream.substr(0, stream.size() - units[index].size()), 0.0);
break; break;
} }
} } while(index != 0);
return (unsigned long long)streamval; return (unsigned long long)streamval;
} }

View File

@ -56,7 +56,7 @@ static inline int process_request(const char *method_str, std::string uri, std::
for(responseRoute &x : responses) for(responseRoute &x : responses)
{ {
if(strcmp(method_str, "OPTIONS") == 0 && x.method == postdata && x.path == path) if(strcmp(method_str, "OPTIONS") == 0 && postdata.find(x.method) != 0 && x.path == path)
{ {
return 1; return 1;
} }