ref: 758edfe57469aa18ecab727313a166882cd35db5
parent: 9d9ab0aad3a5e9123b43b9cf72b758d4ddcdcf2a
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Thu Oct 13 14:12:55 EDT 2011
webfs: fix url fragment bug, preserve fragment on redirect
--- a/sys/src/cmd/webfs/client.c
+++ b/sys/src/cmd/webfs/client.c
@@ -73,7 +73,7 @@
void
clientbodyopen(Client *c, Req *r)
{- char e[ERRMAX], *next;
+ char e[ERRMAX], *next, *frag;
int i, nauth;
Url *u;
@@ -116,6 +116,11 @@
}
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){--- a/sys/src/cmd/webfs/url.c
+++ b/sys/src/cmd/webfs/url.c
@@ -434,7 +434,7 @@
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++ = '#';
--
⑨