mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Enhancements
Add support for specifying node rename pattern in URL argument. Optimize codes.
This commit is contained in:
parent
af7d7fae05
commit
40d3b36f92
@ -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,7 +1189,10 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
std::string proxy = parseProxy(proxy_subscription);
|
||||
|
||||
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
|
||||
if(!emoji.is_undef())
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user