docs: Fix branch prefix detection with dashes (#10965)

* docs: Fix branch prefix detection with dashes

It's perfectly cromulent for branch prefixes to include dashes, but the
existing regex doesn't handle that possibility and generates malformed links as
a result. This adds dashes to the pattern.

* Cache bust docs.js

Co-authored-by: Ryan Blunden <ryan.blunden@gmail.com>
This commit is contained in:
Adam Harvey 2020-05-28 11:54:26 -07:00 committed by GitHub
parent 662ad6a708
commit cae80e4f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -124,7 +124,7 @@ window.sgdocs = (() => {
return
}
let branchPrefix = urlPath.match(/(@[\d\w\.]+)/)[0]
let branchPrefix = urlPath.match(/(@[\d\w\.-]+)/)[0]
document.querySelectorAll('#content-nav a').forEach(e => e.setAttribute('href', `/${branchPrefix}${e.getAttribute('href')}`))
}

View File

@ -446,7 +446,7 @@
{{end}}
{{define "afterBody"}}
<script src="{{asset "docs.js"}}?15"></script>
<script src="{{asset "docs.js"}}?16"></script>
{{with .Content}}
<script>sgdocs.init(breadcrumbs = {{ .Breadcrumbs }});</script>
{{else}}