diff --git a/include/boost/url/impl/url.ipp b/include/boost/url/impl/url.ipp index 5ecf3c851..0543c4b97 100644 --- a/include/boost/url/impl/url.ipp +++ b/include/boost/url/impl/url.ipp @@ -214,6 +214,12 @@ relative( segments_view::iterator& first, segments_view::iterator last) { + if (*first == dotdot || + *first == dot) + { + ++first; + return true; + } auto it = std::next(first); std::size_t l = 1; while (it != last) @@ -241,37 +247,17 @@ relative( it0 != last0 && it1 != last1) { + if (consume_dots(it0, last0)) + continue; + if (consume_dots(it1, last1)) + continue; if (*it0 == *it1) { ++it0; ++it1; } - else if (*it0 == dot) - { - ++it0; - } - else if (*it1 == dot) - { - ++it1; - } - else if (*it0 == dotdot) - { - ++it0; - if (it1 != begin1) - --it1; - } - else if (*it1 == dotdot) - { - ++it1; - if (it0 != begin0) - --it0; - } else { - if (consume_dots(it0, last0)) - continue; - if (consume_dots(it1, last1)) - continue; break; } } diff --git a/test/unit/url.cpp b/test/unit/url.cpp index 15ab85321..73418fce2 100644 --- a/test/unit/url.cpp +++ b/test/unit/url.cpp @@ -2097,7 +2097,7 @@ class url_test check("/a/path/././to/./somewhere/else", "/a/./path/./to/a", "../a"); // ".." should be normalized check("/a/path/x/../to/y/../somewhere/else", "/b/../a/path/to/a", "../a"); - // check("/../path/x/../to/y/../somewhere/else", "/a/../../path/to/a", "../a"); + check("/../path/x/../to/y/../somewhere/else", "/a/../../path/to/a", "../a"); check("/a/path/to/somewhere/else", "/a/path/to/a/../b", "../b"); // same parent check("/relative/file?some=query#hash", "/relative/path?blubber=1#hash1", "path?blubber=1#hash1");