govuk_publishing_components 23.11.1 → 23.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfc403e4ae4e502dac4d0bbc51a5e3c0e454097ea602ef00a1cf0fd3e1ff98fb
4
- data.tar.gz: 2b19a5969e18d37c3643fc800fb24a549487af3443074e7729d541184e16c315
3
+ metadata.gz: e893228b7aeae4913a2e99436d0d892e32200a65162d7965bcc0f15771bc7ee7
4
+ data.tar.gz: c9b253d4e6ed92190ef52f2e625e9e495a7ab643ba8027d2f1f2988806fe369a
5
5
  SHA512:
6
- metadata.gz: 3e9e7ee289c6a1cb4be8fdfba47fe6ca937654ee7fb379c8b1c2b88ff9a2cb890187a9ff7a2b5f850f17ef051f2b6d6e89fc3541acd8317aa7e991f52e6d10a0
7
- data.tar.gz: e35c4c8554dbac78e610c31423d3b7e97f1bc8bfce31a32d3340ce99424d034694fbe868f0d70358d56b61604bfe5374d7be1d20b911b67539c6c9b93f1038a0
6
+ metadata.gz: fd695dffba2fdb7868f4fb20cbfcea406020f83f86bb616d1cb52dec78ab39204675224d0027fd96215140269b8fc28397f62067a7bf778bd6052631b4a5b9ec
7
+ data.tar.gz: 48679f3a6272a937d4097c1f6269c180646a4cf7a4e9c975f5952b434a7302da98c0f350d4206da3ff6a9f38dd10d61392aa8c0bb52f5a63d895102a7e2aa9c4
@@ -10,7 +10,6 @@
10
10
  var externalLinkUploadCustomDimension = options.externalLinkUploadCustomDimension
11
11
  var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname()
12
12
  var externalLinkSelector = 'a[href^="http"]:not(a[href*="' + currentHost + '"])'
13
-
14
13
  $('body').on('click', externalLinkSelector, trackClickEvent)
15
14
 
16
15
  function trackClickEvent (evt) {
@@ -33,7 +32,6 @@
33
32
 
34
33
  GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
35
34
  }
36
-
37
35
  GOVUK.analytics.trackEvent('External Link Clicked', href, options)
38
36
  }
39
37
 
@@ -5,8 +5,9 @@
5
5
 
6
6
  var GOVUK = global.GOVUK || {}
7
7
  var EMAIL_PATTERN = /[^\s=/?&]+(?:@|%40)[^\s=/?&]+/g
8
- var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9][ABD-HJLNPQ-Z]{2}/gi
8
+ var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9](?!refund)[ABD-HJLNPQ-Z]{2,3}/gi
9
9
  var DATE_PATTERN = /\d{4}(-?)\d{2}(-?)\d{2}/g
10
+ var ESCAPE_REGEX_PATTERN = /[|\\{}()[\]^$+*?.]/g
10
11
 
11
12
  // specific URL parameters to be redacted from accounts URLs
12
13
  var RESET_PASSWORD_TOKEN_PATTERN = /reset_password_token=[a-zA-Z0-9-]+/g
@@ -21,9 +22,24 @@
21
22
  return ($('meta[name="govuk:static-analytics:strip-postcodes"]').length > 0)
22
23
  }
23
24
 
25
+ function queryStringParametersToStrip () {
26
+ var value = $('meta[name="govuk:static-analytics:strip-query-string-parameters"]').attr('content')
27
+ var parameters = []
28
+
29
+ if (value) {
30
+ var split = value.split(',')
31
+ for (var i = 0; i < split.length; i++) {
32
+ parameters.push(split[i].trim())
33
+ }
34
+ }
35
+
36
+ return parameters
37
+ }
38
+
24
39
  var pii = function () {
25
40
  this.stripDatePII = shouldStripDates()
26
41
  this.stripPostcodePII = shouldStripPostcodes()
42
+ this.queryStringParametersToStrip = queryStringParametersToStrip()
27
43
  }
28
44
 
29
45
  pii.prototype.stripPII = function (value) {
@@ -43,6 +59,7 @@
43
59
  stripped = stripped.replace(RESET_PASSWORD_TOKEN_PATTERN, 'reset_password_token=[reset_password_token]')
44
60
  stripped = stripped.replace(UNLOCK_TOKEN_PATTERN, 'unlock_token=[unlock_token]')
45
61
  stripped = stripped.replace(STATE_PATTERN, 'state=[state]')
62
+ stripped = this.stripQueryStringParameters(stripped)
46
63
 
47
64
  if (this.stripDatePII === true) {
48
65
  stripped = stripped.replace(DATE_PATTERN, '[date]')
@@ -77,6 +94,17 @@
77
94
  return array
78
95
  }
79
96
 
97
+ pii.prototype.stripQueryStringParameters = function (string) {
98
+ for (var i = 0; i < this.queryStringParametersToStrip.length; i++) {
99
+ var parameter = this.queryStringParametersToStrip[i]
100
+ var escaped = parameter.replace(ESCAPE_REGEX_PATTERN, '\\$&')
101
+ var regexp = new RegExp('((?:\\?|&)' + escaped + '=)(?:[^&#\\s]*)', 'g')
102
+ string = string.replace(regexp, '$1[' + parameter + ']')
103
+ }
104
+
105
+ return string
106
+ }
107
+
80
108
  GOVUK.Pii = pii
81
109
 
82
110
  global.GOVUK = GOVUK
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "23.11.1".freeze
2
+ VERSION = "23.12.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 23.11.1
4
+ version: 23.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config