X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdom%2Furi.cpp;fp=src%2Fdom%2Furi.cpp;h=e65c5edffdd4fa47aedaedea3c3e9508c9de450d;hb=696562dc6f48757cf6e44e7c58a2be50222a662e;hp=59a965b8d942b84ab1c6ee8e95053d3e7ce1c02a;hpb=d7d9ec270cbc180be75921c37aec05cf8cf7e6ec;p=inkscape.git diff --git a/src/dom/uri.cpp b/src/dom/uri.cpp index 59a965b8d..e65c5edff 100644 --- a/src/dom/uri.cpp +++ b/src/dom/uri.cpp @@ -312,10 +312,10 @@ URI URI::resolve(const URI &other) const DOMString tpath = path.substr(0, pos+1); tpath.append(other.path); newUri.path = tpath; - newUri.normalize(); } } } + newUri.normalize(); return newUri; } @@ -340,15 +340,27 @@ void URI::normalize() //## Collect segments if (path.size()<2) return; + bool abs = false; unsigned int pos=0; + if (path[0]=='/') + { + abs = true; + pos++; + } while (pos < path.size()) { - unsigned int pos2 = path.find(pos); + unsigned int pos2 = path.find('/', pos); if (pos2==path.npos) + { + DOMString seg = path.substr(pos); + //printf("last segment:%s\n", seg.c_str()); + segments.push_back(seg); break; + } if (pos2>pos) { - DOMString seg = path.substr(pos, pos2); + DOMString seg = path.substr(pos, pos2-pos); + //printf("segment:%s\n", seg.c_str()); segments.push_back(seg); } pos = pos2; @@ -383,13 +395,16 @@ void URI::normalize() if (edited) { path.clear(); - if (absolute) + if (abs) + { path.append("/"); + } std::vector::iterator iter; for (iter=segments.begin() ; iter!=segments.end() ; iter++) { + if (iter != segments.begin()) + path.append("/"); path.append(*iter); - path.append("/"); } } @@ -633,6 +648,7 @@ bool URI::parse(const DOMString &str) int p = parse(0); + normalize(); if (p < 0) {