Skip to content

Commit

Permalink
fix: avoid out of bounds error when rendering short hashes
Browse files Browse the repository at this point in the history
The panic is caught higher up the stack so it can't crash the node, but
it's still "not good".
  • Loading branch information
Stebalien committed Jul 30, 2021
1 parent cab67f6 commit 8939fd4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/corehttp/gateway_indexPage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func breadcrumbs(urlPath string, dnslinkOrigin bool) []breadcrumb {
}

func shortHash(hash string) string {
if len(hash) <= 8 {
return hash
}
return (hash[0:4] + "\u2026" + hash[len(hash)-4:])
}

Expand Down

0 comments on commit 8939fd4

Please sign in to comment.