webfs: don't fold empty path segments in url
This commit is contained in:
parent
4558207db0
commit
d4da667861
1 changed files with 8 additions and 9 deletions
|
@ -120,11 +120,10 @@ remdot(char *s)
|
||||||
|
|
||||||
dir = 1;
|
dir = 1;
|
||||||
b = d = s;
|
b = d = s;
|
||||||
while(*s == '/')
|
if(*s == '/')
|
||||||
s++;
|
s++;
|
||||||
for(; s; s = p){
|
for(; s; s = p){
|
||||||
if(p = strchr(s, '/'))
|
if(p = strchr(s, '/'))
|
||||||
while(*p == '/')
|
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
if(*s == '.' && ((s[1] == 0) || (s[1] == '.' && s[2] == 0))){
|
if(*s == '.' && ((s[1] == 0) || (s[1] == '.' && s[2] == 0))){
|
||||||
if(s[1] == '.')
|
if(s[1] == '.')
|
||||||
|
@ -135,10 +134,10 @@ remdot(char *s)
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else
|
||||||
dir = (p != nil);
|
dir = (p != nil);
|
||||||
n = strlen(s);
|
if((n = strlen(s)) > 0)
|
||||||
memmove(d+1, s, n);
|
memmove(d+1, s, n);
|
||||||
*d = '/';
|
*d++ = '/';
|
||||||
d += n+1;
|
d += n;
|
||||||
}
|
}
|
||||||
if(dir)
|
if(dir)
|
||||||
*d++ = '/';
|
*d++ = '/';
|
||||||
|
@ -156,7 +155,7 @@ abspath(char *s, char *b)
|
||||||
return estrdup(b);
|
return estrdup(b);
|
||||||
if(*s != '/' && (x = strrchr(b, '/'))){
|
if(*s != '/' && (x = strrchr(b, '/'))){
|
||||||
a = emalloc((x - b) + strlen(s) + 4);
|
a = emalloc((x - b) + strlen(s) + 4);
|
||||||
sprint(a, "/%.*s/%s", (int)(x - b), b, s);
|
sprint(a, "%.*s/%s", (int)(x - b), b, s);
|
||||||
return remdot(a);
|
return remdot(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +163,7 @@ abspath(char *s, char *b)
|
||||||
if(*s != '/')
|
if(*s != '/')
|
||||||
return estrdup(s);
|
return estrdup(s);
|
||||||
a = emalloc(strlen(s) + 4);
|
a = emalloc(strlen(s) + 4);
|
||||||
sprint(a, "/%s", s);
|
sprint(a, "%s", s);
|
||||||
return remdot(a);
|
return remdot(a);
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
|
|
Loading…
Reference in a new issue