webfs: fix url fragment bug, preserve fragment on redirect
This commit is contained in:
parent
46ecc9eff6
commit
e02b84087e
2 changed files with 7 additions and 2 deletions
|
@ -73,7 +73,7 @@ clonectl(Ctl *c)
|
|||
void
|
||||
clientbodyopen(Client *c, Req *r)
|
||||
{
|
||||
char e[ERRMAX], *next;
|
||||
char e[ERRMAX], *next, *frag;
|
||||
int i, nauth;
|
||||
Url *u;
|
||||
|
||||
|
@ -116,6 +116,11 @@ clientbodyopen(Client *c, Req *r)
|
|||
}
|
||||
if((u = parseurl(next, c->url)) == nil)
|
||||
goto Error;
|
||||
/* if there was a redirect, carry over the fragment */
|
||||
if((frag = c->url->fragment) && u->fragment == nil){
|
||||
u->fragment = estrdup(frag);
|
||||
rewriteurl(u);
|
||||
}
|
||||
if(urldebug)
|
||||
fprint(2, "parseurl %s got scheme %d\n", next, u->ischeme);
|
||||
if(u->ischeme == USunknown){
|
||||
|
|
|
@ -434,7 +434,7 @@ resolve_relative(SplitUrl *su, Url *base, Url *u)
|
|||
|
||||
if(su->fragment.s){
|
||||
*purl++ = '#';
|
||||
memmove(purl, su->query.s, su->query.e - su->query.s);
|
||||
memmove(purl, su->fragment.s, su->fragment.e - su->fragment.s);
|
||||
purl += su->fragment.e - su->fragment.s;
|
||||
}else if(currentdoc && base->fragment){
|
||||
*purl++ = '#';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue