diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-04 22:27:58 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-04 22:27:58 +0900 |
| commit | f84d2253b2250ed5760398c189bfc8bf8dff1f69 (patch) | |
| tree | 19a84b1b75161152d5c3c338282596a2537e4c1d /src/uri.cc | |
| parent | 6267676e8bba1566aa68a757359c9481b135cc6d (diff) | |
Rewritten util::split and added its iterator version.
Iterator based functions util::startsWith, util::endsWith,
util::streq, util::strieq were added.
Diffstat (limited to 'src/uri.cc')
| -rw-r--r-- | src/uri.cc | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -307,7 +307,8 @@ std::string joinUri(const std::string& baseUri, const std::string& uri) } std::vector<std::string> parts; if(!util::startsWith(uri, "/")) { - util::split(bus.dir, std::back_inserter(parts), "/"); + util::split(bus.dir.begin(), bus.dir.end(), std::back_inserter(parts), + '/'); } std::string::const_iterator qend; for(qend = uri.begin(); qend != uri.end(); ++qend) { @@ -321,15 +322,13 @@ std::string joinUri(const std::string& baseUri, const std::string& uri) break; } } - std::string path(uri.begin(), end); - util::split(path, std::back_inserter(parts), "/"); + util::split(uri.begin(), end, std::back_inserter(parts), '/'); bus.dir.clear(); bus.file.clear(); bus.query.clear(); std::string res = construct(bus); res += util::joinPath(parts.begin(), parts.end()); - if((path.empty() || util::endsWith(path, "/")) && - !util::endsWith(res, "/")) { + if((uri.begin() == end || *(end-1) == '/') && *(res.end()-1) != '/') { res += "/"; } res.append(end, qend); |
