govuk_publishing_components 57.3.0 → 57.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffe0c2fbfcd53a9c25e9ab76f80625ebae91d098a528892118b658c9142a7641
4
- data.tar.gz: f69ad84e0d5cc39772ddb557f50771e229db6a09c5a0e384adadfcc8630ccd7f
3
+ metadata.gz: 41a446b912bf0ceb75ba5700eeff0f6d91b976039d175fe9262e44ed75fbd420
4
+ data.tar.gz: 18c75d217261b9b6793f251cc2020fa785da20f31aa47ada9721dbb642a4ccb8
5
5
  SHA512:
6
- metadata.gz: 6fb6267d1fb31f6f7e557ee3259a1808739e9ad9a9803102790729b139cd9d96683983136105588b3b576e57e41f8884315a041fe89a06a7231f5cf641e041e2
7
- data.tar.gz: d349cc3c24e05d6af50dc4eb6dfe528a3954ce7f535b8deb255682125c03f9d943f98d58c2867a9b1716000eff05c40f40d7e8d01a79c31e00e028b7838e748c
6
+ metadata.gz: d3ee818d7df8773727db46921ba33a905de236ed76b4a3c00d5aad2394cf26513fbc6a1039926e7ac29466ec98d1e25b98701d49cfcd10e7c663abb1f23aaaf9
7
+ data.tar.gz: 46bb83df7af008ed114877f485b4888789c1e72b7876692c10a025e631df2391a99ee4c631e5d5ec3325c3a517d8cda520e20fd4c2832d6dc0d900e75577afcd
@@ -25,8 +25,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
25
25
 
26
26
  if (eventData) {
27
27
  item.dataset.ga4Event = eventData.dataset.ga4Event
28
+ item.dataset.indexSection = event.oldIndex
28
29
  item.dataset.action = 'drag and drop'
29
- item.dataset.text = event.newIndex > event.oldIndex ? 'Up' : 'Down'
30
+ item.dataset.text = event.newIndex > event.oldIndex ? 'Down' : 'Up'
30
31
  this.triggerEvent(item, 'click')
31
32
  delete item.dataset.ga4Event
32
33
  }
@@ -20,7 +20,7 @@
20
20
  }
21
21
 
22
22
  YoutubeLinkEnhancement.prototype.paragraphHasOtherContent = function (paragraph, link) {
23
- return paragraph.innerHTML.replaceAll(this.punctuationRegex, '') !== link.outerHTML.replaceAll(this.punctuationRegex, '')
23
+ return paragraph.innerHTML.replaceAll(this.punctuationRegex, '').trim() !== link.outerHTML.replaceAll(this.punctuationRegex, '').trim()
24
24
  }
25
25
 
26
26
  YoutubeLinkEnhancement.prototype.decorateLink = function () {
@@ -222,6 +222,17 @@
222
222
  }
223
223
  }
224
224
 
225
+ YoutubeLinkEnhancement.sanitiseVideoId = function (pathname) {
226
+ // YouTube links can now contain an ?si= param in the URL.
227
+ // This usually only appears on youtu.be links but it's appearing for us on youtube.com URLs due to some Whitehall regex being outdated.
228
+ // Therefore we need to use regex to remove it from the path.
229
+ // E.g. youtube.com/watch?v=[video-id]?si=ABCzJtVWBAZ2o_l3
230
+ // ?=si in this case isn't a valid query parameter as it isn't using an &, so we can't use JS' native URL API to filter it out.
231
+ if (pathname) {
232
+ return pathname.replace(/(\?|&)(.+)=.+/g, '')
233
+ }
234
+ }
235
+
225
236
  // This is a public class method so it can be used outside of this embed to
226
237
  // check that user input for videos will be supported in govspeak
227
238
  YoutubeLinkEnhancement.parseVideoId = function (url) {
@@ -232,9 +243,10 @@
232
243
  } catch (e) { return undefined }
233
244
 
234
245
  if (u.host === 'www.youtube.com' || u.host === 'youtube.com') {
235
- return u.searchParams.get('v') || undefined
246
+ return this.sanitiseVideoId(u.searchParams.get('v')) || undefined
236
247
  } else if (u.host === 'youtu.be') {
237
- return u.pathname.slice(1) // Trim the leading /
248
+ var pathName = u.pathname.slice(1) // Trim the leading /
249
+ return this.sanitiseVideoId(pathName)
238
250
  }
239
251
  }
240
252
 
@@ -150,7 +150,7 @@ examples:
150
150
  url: '/government/organisations/hm-prison-service'
151
151
  brand: 'ministry-of-justice'
152
152
  image:
153
- url: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/organisation/logo/321/HMPS.jpg'
153
+ url: 'https://assets.publishing.service.gov.uk/media/6850134301d3b0e7b62da740/hmps_25_gov_240x188.png'
154
154
  alt_text: 'HM Prison Service'
155
155
  without_a_link:
156
156
  data:
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "57.3.0".freeze
2
+ VERSION = "57.3.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 57.3.0
4
+ version: 57.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev