summaryrefslogtreecommitdiffstats
path: root/transform
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-09-18 15:48:36 -0700
committerNoah Campbell <noahcampbell@gmail.com>2013-09-18 15:48:36 -0700
commit784077da4dcc3476f61bbf99c5f873b71694dd64 (patch)
tree1ae8a1da051036cb56794c27b50c415820400b1d /transform
parent311e10222301d47422f970c460383879ad78f681 (diff)
Fix fragments being AbsUrlified in final html
Found that fragments were getting the BaseURL applied creating a proper anchor url and redirecting off the page.
Diffstat (limited to 'transform')
-rw-r--r--transform/post.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/transform/post.go b/transform/post.go
index 369b2d6ca..be383700d 100644
--- a/transform/post.go
+++ b/transform/post.go
@@ -39,6 +39,9 @@ func (t *Transformer) absUrlify(tr *htmltran.Transformer, selectors ...elattr) (
if inURL, err = url.Parse(in); err != nil {
return in + "?"
}
+ if fragmentOnly(inURL) {
+ return in
+ }
return baseURL.ResolveReference(inURL).String()
}
@@ -50,3 +53,7 @@ func (t *Transformer) absUrlify(tr *htmltran.Transformer, selectors ...elattr) (
return
}
+
+func fragmentOnly(u *url.URL) bool {
+ return u.Fragment != "" && u.Scheme == "" && u.Opaque == "" && u.User == nil && u.Host == "" && u.Path == "" && u.Path == "" && u.RawQuery == ""
+}