URL模块URLParams入参为%2B时get()出结果会错误显示为空格,实际应为+

https://gitee.com/openharmony/commonlibrary_ets_utils/issues/I9NMJJ

Signed-off-by: zWX1234017 <zhaoduwei3@huawei.com>
This commit is contained in:
zWX1234017 2024-05-08 20:50:29 +08:00
parent 9fb9818652
commit f7f5cffdcc
2 changed files with 2 additions and 15 deletions

View File

@ -688,17 +688,6 @@ namespace OHOS::Url {
return result;
}
static void IsPlusSign(size_t &strLastPos, const size_t &iteaor, std::string &buf, std::string &stringParm)
{
if (strLastPos < iteaor) {
buf += stringParm.substr(strLastPos, iteaor - strLastPos + 1);
} else {
buf += "";
}
strLastPos = iteaor + 1;
return;
}
static void IsEqualSign(size_t &strLastPos, const size_t &iteaor,
std::string &buf, std::string &stringParm, std::vector<std::string> &seachParasVec)
{
@ -769,9 +758,6 @@ namespace OHOS::Url {
isHasSpace = true;
break;
}
case '+':
IsPlusSign(strLastPos, iteaor, buf, stringParm);
break;
default:break;
}
}

View File

@ -94,6 +94,7 @@ function decodeSafelyInner(input: string): string {
if (input === undefined || input === '') {
return input;
}
input = input.replaceAll('+', ' ');
const regex = /(%[a-f0-9A-F]{2})|[^%]+/g;
let outStr = input.match(regex).map(part => {
if (part.startsWith('%')) {
@ -105,7 +106,7 @@ function decodeSafelyInner(input: string): string {
}
return part;
}).join('');
return outStr.replaceAll('+', ' ');
return outStr;
}
function customEncodeURIComponent(str: string | number): string {