[core] replace <regex> usage with plain string code to reduce binary size
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -195,11 +194,19 @@ std::string canonicalizeTileURL(const std::string& url, SourceType type, uint16_
|
|||||||
|
|
||||||
// get the query and remove access_token, if more parameters exist, add them to the final result
|
// get the query and remove access_token, if more parameters exist, add them to the final result
|
||||||
if (queryIdx != url.length()) {
|
if (queryIdx != url.length()) {
|
||||||
const auto query = url.substr(queryIdx + 1);
|
auto idx = queryIdx;
|
||||||
std::regex re ("&?access_token=([^&]*)");
|
bool hasQuery = false;
|
||||||
std::string replace = std::regex_replace(query, re, "");
|
while (idx != std::string::npos) {
|
||||||
std::string subQuery = (replace.find("&") == 0) ? replace.substr(1, replace.length()) : replace;
|
idx++; // skip & or ?
|
||||||
if (subQuery.length() > 0) result += "?" + subQuery;
|
auto ampersandIdx = url.find("&", idx);
|
||||||
|
if (url.substr(idx, 13) != "access_token=") {
|
||||||
|
result += hasQuery ? "&" : "?";
|
||||||
|
result += url.substr(idx, ampersandIdx != std::string::npos ? ampersandIdx - idx
|
||||||
|
: std::string::npos);
|
||||||
|
hasQuery = true;
|
||||||
|
}
|
||||||
|
idx = ampersandIdx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user