diff --git a/routes/artworks.cpp b/routes/artworks.cpp index 8b7ddea..78c6c97 100644 --- a/routes/artworks.cpp +++ b/routes/artworks.cpp @@ -125,17 +125,25 @@ static inline std::vector parse_description_line(const http std::smatch sm; while (std::regex_search(str, sm, blankie::murl::full_url_regex)) { - if (sm.prefix().length()) { - nodes.push_back(sm.prefix()); + std::string prefix = sm.prefix(); + std::string url_str = sm.str(0); + std::string suffix = sm.suffix(); + + if (prefix.ends_with('(') && url_str.ends_with(')')) { + url_str.pop_back(); + suffix.insert(0, 1, ')'); + } + if (!prefix.empty()) { + nodes.push_back(std::move(prefix)); } - blankie::murl::Url url(sm.str(0)); - std::string url_str = url.is_host_equal("pixiv.net") || url.is_host_equal("www.pixiv.net") + blankie::murl::Url url(std::move(url_str)); + url_str = url.is_host_equal("pixiv.net") || url.is_host_equal("www.pixiv.net") ? proxy_pixiv_url(req, config, std::move(url)) : url.to_string(); nodes.push_back(Element("a", {{"href", url_str}}, {url_str})); - str = sm.suffix(); + str = std::move(suffix); } if (!str.empty()) { nodes.push_back(std::move(str));