govuk_personalisation 0.8.0 → 0.9.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c790c79fa0ba26b2b84efecd07532446c2497cbfd874586526b65f589ba715ca
|
4
|
+
data.tar.gz: 899f016d1a906e2fe2893b62da8999e33edc9b7c8ae6df9d6caee6ce9c14aa28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0398288ee33c9a21186c833fec51049b38f49e62b7d6e649970599ffae8ae7a3a0096100fc17b325b1f63698030dc7c31c2a2350206b3af65c0bd3fb46e36bd8'
|
7
|
+
data.tar.gz: 2ca84334520a9521f79ca1e49a1a3f36af4e1fc0bccaa5c855f9f4b19628c6909a68af91c3388266039fec8afc2ce8c1883bd8be8aecba36567dd6d3a51c5fe0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 0.9.0
|
2
|
+
- Add `redirect_with_analytics` helper, attaches _ga and cookie_consent values from existing params to redirects. ([#19](https://github.com/alphagov/govuk_personalisation/pull/19))
|
3
|
+
- Add `GovukPersonalisation::Redirect` and `.build_url` helper to construct valid URLs with additional parameters. ([#19](https://github.com/alphagov/govuk_personalisation/pull/19))
|
4
|
+
|
1
5
|
# 0.8.0
|
2
6
|
|
3
7
|
- Change sign in path to `/sign-in/redirect` ([#17](https://github.com/alphagov/govuk_personalisation/pull/17))
|
@@ -125,5 +125,13 @@ module GovukPersonalisation
|
|
125
125
|
@new_account_flash = @account_flash.merge(@new_account_flash)
|
126
126
|
set_account_session_header
|
127
127
|
end
|
128
|
+
|
129
|
+
# Redirect to a URL adding parameters necessary for cross-domain analytics
|
130
|
+
# and cookie consent
|
131
|
+
#
|
132
|
+
# @param url [String] The URL to redirect to
|
133
|
+
def redirect_with_analytics(url)
|
134
|
+
redirect_to GovukPersonalisation::Redirect.build_url(url, params.permit(:_ga, :cookie_consent).to_h)
|
135
|
+
end
|
128
136
|
end
|
129
137
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module GovukPersonalisation::Redirect
|
2
|
+
# Builds a URL with additional query parameters
|
3
|
+
#
|
4
|
+
# Allows for a simple method call to add params on to an existing
|
5
|
+
# URL, for instance when adding _ga tracking params to a redirect
|
6
|
+
#
|
7
|
+
# @param base_url [String] The URL to attach additional parameters to
|
8
|
+
# @param optional additional_params [Hash{String,Symbol => String}] additional parameters
|
9
|
+
# to be added to the URL. If empty, returns the base URL.
|
10
|
+
#
|
11
|
+
# @return [String] a new URL with additional parameters
|
12
|
+
def self.build_url(base_url, additional_params = {})
|
13
|
+
return base_url if additional_params.empty?
|
14
|
+
|
15
|
+
additional_query = additional_params.to_a.map { |param| param.join("=") }.join("&")
|
16
|
+
|
17
|
+
if base_url.include? "?"
|
18
|
+
"#{base_url}&#{additional_query}"
|
19
|
+
else
|
20
|
+
"#{base_url}?#{additional_query}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "govuk_personalisation/version"
|
4
4
|
require "govuk_personalisation/controller_concern"
|
5
5
|
require "govuk_personalisation/flash"
|
6
|
+
require "govuk_personalisation/redirect"
|
6
7
|
require "govuk_personalisation/test_helpers/features"
|
7
8
|
require "govuk_personalisation/test_helpers/requests"
|
8
9
|
require "govuk_personalisation/urls"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_personalisation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/govuk_personalisation.rb
|
147
147
|
- lib/govuk_personalisation/controller_concern.rb
|
148
148
|
- lib/govuk_personalisation/flash.rb
|
149
|
+
- lib/govuk_personalisation/redirect.rb
|
149
150
|
- lib/govuk_personalisation/test_helpers/features.rb
|
150
151
|
- lib/govuk_personalisation/test_helpers/requests.rb
|
151
152
|
- lib/govuk_personalisation/urls.rb
|