summaryrefslogtreecommitdiffstats
path: root/src/dom/uri.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2006-04-22 21:50:15 +0000
committerishmal <ishmal@users.sourceforge.net>2006-04-22 21:50:15 +0000
commit91d9d0af5b3d051dbc966a79b207526c0ef4e2cd (patch)
tree780954976942ca8967edb9829ceeb185f0354296 /src/dom/uri.cpp
parentConfig tweaks (diff)
downloadinkscape-91d9d0af5b3d051dbc966a79b207526c0ef4e2cd.tar.gz
inkscape-91d9d0af5b3d051dbc966a79b207526c0ef4e2cd.zip
Fix normalize()
(bzr r569)
Diffstat (limited to 'src/dom/uri.cpp')
-rw-r--r--src/dom/uri.cpp26
1 files changed, 21 insertions, 5 deletions
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<DOMString>::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)
{