MCPcopy Create free account
hub / github.com/comaps/comaps / ValidateAndFormat_url

Method ValidateAndFormat_url

generator/osm2meta.cpp:120–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120std::string MetadataTagProcessorImpl::ValidateAndFormat_url(std::string const & v)
121{
122 // Remove the last slash if it's after the hostname to beautify URLs in the UI and save a byte of space:
123 // https://www.test.com/ => https://www.test.com
124 // www.test.com/ => www.test.com
125 // www.test.com/path => www.test.com/path
126 // www.test.com/path/ => www.test.com/path/
127 constexpr std::string_view kHttps = "https://";
128 constexpr std::string_view kHttp = "http://";
129 size_t start = 0;
130 if (v.starts_with(kHttps))
131 start = kHttps.size();
132 else if (v.starts_with(kHttp))
133 start = kHttp.size();
134 auto const first = v.find('/', start);
135 if (first == std::string::npos)
136 return v;
137 if (first + 1 == v.size())
138 return std::string{v.begin(), --v.end()};
139 return v;
140}
141
142std::string MetadataTagProcessorImpl::ValidateAndFormat_text(std::string const & v)
143{

Callers 1

UNIT_TESTFunction · 0.80

Calls 4

sizeMethod · 0.45
findMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64