Skip to content

Commit

Permalink
golang/pkgsite: improve hostname verification to ensure origin before…
Browse files Browse the repository at this point in the history
… setting cookie

Updates frontend to only check for `*.go.dev` / `go.dev`, instead of `*go.dev`

Change-Id: I1460aa69f2f032f9a098a22651586bb737927453
GitHub-Last-Rev: 61741be
GitHub-Pull-Request: #88
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/574655
Reviewed-by: Aviv Keller <[email protected]>
TryBot-Bypass: Jonathan Amsterdam <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
Reviewed-by: David Chase <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
  • Loading branch information
RedYetiDev authored and jba committed Apr 10, 2024
1 parent 29d7d25 commit 493d85e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions static/frontend/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function toggleTheme() {
nextTheme = 'auto';
}
let domain = '';
if (location.hostname.endsWith('go.dev')) {
if (location.hostname === 'go.dev' || location.hostname.endsWith(".go.dev")) {
domain = 'domain=.go.dev;';
}
document.documentElement.setAttribute('data-theme', nextTheme);
Expand All @@ -147,7 +147,7 @@ function registerCookieNotice() {
notice?.classList.add('Cookie-notice--visible');
button?.addEventListener('click', () => {
let domain = '';
if (location.hostname.endsWith('go.dev')) {
if (location.hostname === 'go.dev' || location.hostname.endsWith(".go.dev")) {
// Apply the cookie to *.go.dev.
domain = 'domain=.go.dev;';
}
Expand Down

0 comments on commit 493d85e

Please sign in to comment.