Skip to content

Commit

Permalink
Take cookies domain from data-tnacookiesdomain on <html> if available
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Dec 9, 2024
1 parent 5b742f9 commit af6058d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/nationalarchives/tna-frontend/compare/v0.3.0...HEAD)

### Added

- The `data-tnacookiesdomain` attribute of the `<html>` element can be used to define the domain for cookies

### Changed

- Shifted and split hero components no longer assume a contrasted background by default
Expand Down
9 changes: 7 additions & 2 deletions src/nationalarchives/lib/cookies.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class Cookies {
constructor(options = {}) {
const {
extraPolicies = [],
domain = "",
domain = null,
path = "/",
secure = true,
policiesKey = "cookies_policy",
Expand All @@ -96,7 +96,12 @@ export default class Cookies {
return window.TNAFrontendCookies;
}
this.extraPolicies = extraPolicies;
this.domain = domain;
if (domain === null) {
this.domain =
document.documentElement.getAttribute("data-tnacookiesdomain") || "";
} else {
this.domain = domain;
}
this.path = path;
this.secure = secure;
this.policiesKey = policiesKey;
Expand Down

0 comments on commit af6058d

Please sign in to comment.