Skip to content

Commit

Permalink
Merge pull request #2705 from alphagov/revert-2034
Browse files Browse the repository at this point in the history
Revert #2034
  • Loading branch information
alex-ju authored Feb 18, 2022
2 parents 924a768 + d866d7e commit 34d789f
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions app/assets/javascripts/global-bar-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,6 @@ var globalBarInit = {
return new RegExp(paths.join('|')).test(window.location.pathname)
},

checkDuplicateCookie: function () {
var cookies = document.cookie.split(';')
var matches = 0
var i

for (i = 0; i < cookies.length; i++) {
if (cookies[i] && cookies[i].indexOf('global_bar_seen') !== -1) {
matches++
}
}

if (matches > 1) {
var possiblePaths = window.location.pathname.split('/')
var pathString = ''

// The duplicate cookie will have a path set to something other than "/".
// The cookie will only surface on that path or it's sub-paths
// As there isn't a way of directly finding out the path, we need to try cookie deletion with all path combinations possible on the current URL.
for (i = 0; i < possiblePaths.length; i++) {
if (possiblePaths[i] !== '') {
pathString = pathString + '/' + possiblePaths[i]
document.cookie = 'global_bar_seen=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=' + pathString
}
}
}
},

setBannerCookie: function () {
var cookieCategory = window.GOVUK.getCookieCategory(GLOBAL_BAR_SEEN_COOKIE)
var cookieConsent = GOVUK.getConsentCookie()
Expand All @@ -95,11 +68,6 @@ var globalBarInit = {
var currentCookieVersion

if (!globalBarInit.urlBlockList()) {
// We had a bug which meant that the global_bar_seen cookie was sometimes set more than once.
// This bug has now been fixed, but some users will be left with these duplicate cookies and therefore will continue to see the issue.
// We need to check for duplicate cookies so we can delete them
globalBarInit.checkDuplicateCookie()

if (globalBarInit.getLatestCookie() === null) {
globalBarInit.setBannerCookie()
globalBarInit.makeBannerVisible()
Expand Down

0 comments on commit 34d789f

Please sign in to comment.