Fixed non-working Wikimedia links with ? character in a title
Signed-off-by: alnzrv <7187657+alnzrv@users.noreply.github.com>
This commit is contained in:
parent
52b616e18c
commit
a7aa9a9b6e
1 changed files with 12 additions and 1 deletions
|
@ -50,11 +50,22 @@ std::string Metadata::GetWikiURL() const
|
|||
return ToWikiURL(string(Get(FMD_WIKIPEDIA)));
|
||||
}
|
||||
|
||||
string Metadata::ToWikimediaCommonsURL(std::string const & v)
|
||||
string Metadata::ToWikimediaCommonsURL(std::string v)
|
||||
{
|
||||
if (v.empty())
|
||||
return v;
|
||||
|
||||
// ? character should be corrected to form a valid URL's path.
|
||||
for (auto i = 0; i < v.size(); ++i)
|
||||
{
|
||||
auto & c = v[i];
|
||||
if (c == '?')
|
||||
{
|
||||
c = '%';
|
||||
v.insert(i + 1, "3F"); // ? => %3F
|
||||
}
|
||||
}
|
||||
|
||||
return "https://commons.wikimedia.org/wiki/" + v;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue