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 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 ext_rename = UrlDecode(getUrlArg(argument, "rename"));
/// switches with default value
tribool upload = getUrlArg(argument, "upload"), emoji = getUrlArg(argument, "emoji");
@ -1188,6 +1189,9 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
std::string proxy = parseProxy(proxy_subscription);
ext.emoji_array = safe_get_emojis();
if(ext_rename.size())
ext.rename_array = split(ext_rename, "`");
else
ext.rename_array = safe_get_renames();
//check other flags

View File

@ -2125,14 +2125,16 @@ static inline unsigned long long streamToInt(const std::string &stream)
return 0;
double streamval = 1.0;
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]))
{
streamval = std::pow(1024, index) * to_number<float>(stream.substr(0, stream.size() - units[index].size()), 0.0);
break;
}
}
} while(index != 0);
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)
{
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;
}