Use absolute paths

This commit is contained in:
Ken-Håvard Lieng 2018-11-22 08:04:04 +01:00
parent 65e103fd23
commit 05527e41b7
3 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@
<link rel="preload" href="/font/RobotoMono-Bold.woff2" as="font" type="font/woff2" crossorigin> <link rel="preload" href="/font/RobotoMono-Bold.woff2" as="font" type="font/woff2" crossorigin>
<% if cssPath != "" { %> <% if cssPath != "" { %>
<link href="<%== cssPath %>" rel="stylesheet"> <link href="/<%== cssPath %>" rel="stylesheet">
<% } %> <% } %>
<link rel="manifest" href="/manifest.json"> <link rel="manifest" href="/manifest.json">
@ -34,7 +34,7 @@
<div id="root"></div> <div id="root"></div>
<% for _, script := range scripts { %> <% for _, script := range scripts { %>
<script src="<%== script %>"></script> <script src="/<%== script %>"></script>
<% } %> <% } %>
<noscript>This page needs JavaScript enabled to function.</noscript> <noscript>This page needs JavaScript enabled to function.</noscript>

View File

@ -11,13 +11,13 @@ io.WriteString(w, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\
io.WriteString(w, inlineScript ) io.WriteString(w, inlineScript )
io.WriteString(w, "</script><link rel=\"preload\" href=\"/font/fontello.woff2?48901973\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/RobotoMono-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/Montserrat-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/Montserrat-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/RobotoMono-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>") io.WriteString(w, "</script><link rel=\"preload\" href=\"/font/fontello.woff2?48901973\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/RobotoMono-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/Montserrat-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/Montserrat-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin><link rel=\"preload\" href=\"/font/RobotoMono-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin>")
if cssPath != "" { if cssPath != "" {
io.WriteString(w, "<link href=\"") io.WriteString(w, "<link href=\"/")
io.WriteString(w, cssPath ) io.WriteString(w, cssPath )
io.WriteString(w, "\" rel=\"stylesheet\">") io.WriteString(w, "\" rel=\"stylesheet\">")
} }
io.WriteString(w, "<link rel=\"manifest\" href=\"/manifest.json\"></head><body><div id=\"root\"></div>") io.WriteString(w, "<link rel=\"manifest\" href=\"/manifest.json\"></head><body><div id=\"root\"></div>")
for _, script := range scripts { for _, script := range scripts {
io.WriteString(w, "<script src=\"") io.WriteString(w, "<script src=\"/")
io.WriteString(w, script ) io.WriteString(w, script )
io.WriteString(w, "\"></script>") io.WriteString(w, "\"></script>")
} }

View File

@ -120,7 +120,7 @@ func (d *Dispatch) initFileServer() {
} }
file := &File{ file := &File{
Path: assetName, Path: "/" + assetName,
Asset: asset, Asset: asset,
ContentType: contentTypes[filepath.Ext(assetName)], ContentType: contentTypes[filepath.Ext(assetName)],
CacheControl: longCacheControl, CacheControl: longCacheControl,
@ -235,7 +235,7 @@ func (d *Dispatch) serveFiles(w http.ResponseWriter, r *http.Request) {
} }
for _, file := range files { for _, file := range files {
if strings.HasSuffix(r.URL.Path, file.Path) { if r.URL.Path == file.Path {
d.serveFile(w, r, file) d.serveFile(w, r, file)
return return
} }