Skip to content

Commit

Permalink
Merge pull request #2101 from alphagov/regex-for-exact-match
Browse files Browse the repository at this point in the history
Now matches the exact path for url blocking
  • Loading branch information
DilwoarH authored Mar 23, 2020
2 parents a0b2b3b + a8a94eb commit f7bb055
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/assets/javascripts/global-bar-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ var globalBarInit = {

urlBlockList: function() {
var paths = [
"/done",
"/transition-check",
"/coronavirus"
"^/done",
"^/transition-check$",
"^/coronavirus$"
]

var ctaLink = document.querySelector('.js-call-to-action')
if (ctaLink) {
paths.push(ctaLink.getAttribute('href'))
var ctaPath = "^" + ctaLink.getAttribute('href') + "$"
paths.push(ctaPath)
}

return new RegExp(paths.join("|")).test(window.location.pathname)
Expand Down

0 comments on commit f7bb055

Please sign in to comment.