Commit 9aeb23df authored by Max Kellermann's avatar Max Kellermann

db/upnp/Util: use string::back(), string::front()

parent e59d8c93
...@@ -46,11 +46,11 @@ std::string ...@@ -46,11 +46,11 @@ std::string
caturl(const std::string &s1, const std::string &s2) caturl(const std::string &s1, const std::string &s2)
{ {
std::string out(s1); std::string out(s1);
if (out[out.size()-1] == '/') { if (out.back() == '/') {
if (s2[0] == '/') if (s2.front() == '/')
out.erase(out.size()-1); out.erase(out.size()-1);
} else { } else {
if (s2[0] != '/') if (s2.front() != '/')
out.push_back('/'); out.push_back('/');
} }
out += s2; out += s2;
...@@ -60,7 +60,7 @@ caturl(const std::string &s1, const std::string &s2) ...@@ -60,7 +60,7 @@ caturl(const std::string &s1, const std::string &s2)
static void static void
path_catslash(std::string &s) path_catslash(std::string &s)
{ {
if (s.empty() || s[s.length() - 1] != '/') if (s.empty() || s.back() != '/')
s += '/'; s += '/';
} }
...@@ -73,7 +73,7 @@ path_getfather(const std::string &s) ...@@ -73,7 +73,7 @@ path_getfather(const std::string &s)
if (father.empty()) if (father.empty())
return "./"; return "./";
if (father[father.length() - 1] == '/') { if (father.back() == '/') {
// Input ends with /. Strip it, handle special case for root // Input ends with /. Strip it, handle special case for root
if (father.length() == 1) if (father.length() == 1)
return father; return father;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment