govuk_publishing_components 57.0.0 → 57.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8767b5e700d2cf0da57d46943ed8ed4e645f510fb872ecc422293270abf339b
|
4
|
+
data.tar.gz: 375137a4c58f557ae925e83cb03bd59e80da2198f87c846c26ed608741e141fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d6b71754931f043138955f7762a252c0763cf5e59f01fa168589268586e92f83d2e50ec7908d249815ab0132467af7cbd4b6132ecbf8c67b62ba2012eb36cab
|
7
|
+
data.tar.gz: 93b9a850cef309bfb5f37ceef3e7716f958186c26bad463681a3f6419a9eb570209e75fe7c0361186aa1bf940868887e2719a0ed840fd1bf23a251c42c856009
|
@@ -16,8 +16,15 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
|
|
16
16
|
if (!text) {
|
17
17
|
return // do nothing if no text has been selected
|
18
18
|
}
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
var target = event.target
|
21
|
+
|
22
|
+
if (target.closest && target.closest('[data-ga4-no-copy]')) {
|
23
|
+
return // do nothing if data-ga4-no-copy present
|
24
|
+
}
|
25
|
+
|
26
|
+
var tagName = target.tagName
|
27
|
+
if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
|
21
28
|
return // do nothing if text is being copied from an input
|
22
29
|
}
|
23
30
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Middleware
|
3
|
+
class Ga4Optimise
|
4
|
+
DATA_GA4_REGEX = /data-ga4-(?:link|event|form|focus-loss)=("[^"]*")/
|
5
|
+
|
6
|
+
def initialize(app)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
status, headers, response = @app.call(env)
|
12
|
+
return [status, headers, safe_body_from_response(response)] unless headers["content-type"]&.start_with?("text/html")
|
13
|
+
|
14
|
+
body = response.each.first
|
15
|
+
matched_sections = body.scan(DATA_GA4_REGEX)
|
16
|
+
|
17
|
+
if matched_sections.any?
|
18
|
+
matched_sections.each do |section|
|
19
|
+
body.sub!(section.first, section.first.gsub('"', "'").gsub(""\;", '"'))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
[status, headers, [body]]
|
24
|
+
end
|
25
|
+
|
26
|
+
def safe_body_from_response(response)
|
27
|
+
return [response.body] if response.respond_to?(:body)
|
28
|
+
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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.
|
4
|
+
version: 57.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -961,6 +961,7 @@ files:
|
|
961
961
|
- lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb
|
962
962
|
- lib/govuk_publishing_components/config.rb
|
963
963
|
- lib/govuk_publishing_components/engine.rb
|
964
|
+
- lib/govuk_publishing_components/middleware/ga4_optimise.rb
|
964
965
|
- lib/govuk_publishing_components/minitest/component_guide_test.rb
|
965
966
|
- lib/govuk_publishing_components/presenters/absolute_links_helper.rb
|
966
967
|
- lib/govuk_publishing_components/presenters/accordion_helper.rb
|