Skip to content

Commit dd5ae8f

Browse files
igba1980igba.ujege
andauthored
Update search and replace regex patterns for NHS website non prod links (#152)
* Update search and replace regex patterns for NHS website non prod links * Add regex pattern for replacing NHS website content API manifest page links * Amended regex pattern for NHS website content API manifest links * Update regex pattern for NHS website content API manifest links * Update regex pattern * Update regex pattern * Update regex pattern to allow optional quotes in NHS website content API manifest links * reverted regex * Update regex pattern for NHS website content API manifest links to use the development environment URL --------- Co-authored-by: igba.ujege <igba.ujege@bjss.com>
1 parent 78eacc3 commit dd5ae8f

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

proxies/live/apiproxy/resources/jsc/SearchAndReplaceResponse.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ var searchAndReplaceStrings = [
2828
replaceWithStr:
2929
': "https://' + requestHostnameEnv + "/nhs-website-content/conditions/",
3030
},
31+
{
32+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/conditions\//gm,
33+
replaceWithStr:
34+
': "https://' + requestHostnameEnv + "/nhs-website-content/conditions/",
35+
},
3136
{
3237
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/conditions\//gm,
3338
replaceWithStr:
@@ -42,6 +47,10 @@ var searchAndReplaceStrings = [
4247
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/conditions\//gm,
4348
replaceWithStr: 'href=\\"https://www.nhs.uk/conditions/',
4449
},
50+
{
51+
searchForRegex: /href=\\"https:\/\/nhswebsite-dev.nhs.uk\/conditions\//gm,
52+
replaceWithStr: 'href=\\"https://www.nhs.uk/conditions/',
53+
},
4554
{
4655
searchForRegex: /href=\\"\/conditions\//gm,
4756
replaceWithStr: 'href=\\"https://www.nhs.uk/conditions/',
@@ -56,6 +65,11 @@ var searchAndReplaceStrings = [
5665
replaceWithStr:
5766
': "https://' + requestHostnameEnv + "/nhs-website-content/live-well/",
5867
},
68+
{
69+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/live-well\//gm,
70+
replaceWithStr:
71+
': "https://' + requestHostnameEnv + "/nhs-website-content/live-well/",
72+
},
5973
{
6074
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/live-well\//gm,
6175
replaceWithStr:
@@ -70,6 +84,10 @@ var searchAndReplaceStrings = [
7084
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/live-well\//gm,
7185
replaceWithStr: 'href=\\"https://www.nhs.uk/live-well/',
7286
},
87+
{
88+
searchForRegex: /href=\\"https:\/\/nhswebsite-dev.nhs.uk\/live-well\//gm,
89+
replaceWithStr: 'href=\\"https://www.nhs.uk/live-well/',
90+
},
7391
{
7492
searchForRegex: /href=\\"\/live-well\//gm,
7593
replaceWithStr: 'href=\\"https://www.nhs.uk/live-well/',
@@ -86,6 +104,13 @@ var searchAndReplaceStrings = [
86104
requestHostnameEnv +
87105
"/nhs-website-content/mental-health/",
88106
},
107+
{
108+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/mental-health\//gm,
109+
replaceWithStr:
110+
': "https://' +
111+
requestHostnameEnv +
112+
"/nhs-website-content/mental-health/",
113+
},
89114
{
90115
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/mental-health\//gm,
91116
replaceWithStr:
@@ -104,6 +129,11 @@ var searchAndReplaceStrings = [
104129
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/mental-health\//gm,
105130
replaceWithStr: 'href=\\"https://www.nhs.uk/mental-health/',
106131
},
132+
{
133+
searchForRegex:
134+
/href=\\"https:\/\/nhswebsite-dev.nhs.uk\/mental-health\//gm,
135+
replaceWithStr: 'href=\\"https://www.nhs.uk/mental-health/',
136+
},
107137
{
108138
searchForRegex: /href=\\"\/mental-health\//gm,
109139
replaceWithStr: 'href=\\"https://www.nhs.uk/mental-health/',
@@ -118,6 +148,11 @@ var searchAndReplaceStrings = [
118148
replaceWithStr:
119149
': "https://' + requestHostnameEnv + "/nhs-website-content/medicines/",
120150
},
151+
{
152+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/medicines\//gm,
153+
replaceWithStr:
154+
': "https://' + requestHostnameEnv + "/nhs-website-content/medicines/",
155+
},
121156
{
122157
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/medicines\//gm,
123158
replaceWithStr:
@@ -132,6 +167,10 @@ var searchAndReplaceStrings = [
132167
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/medicines\//gm,
133168
replaceWithStr: 'href=\\"https://www.nhs.uk/medicines/',
134169
},
170+
{
171+
searchForRegex: /href=\\"https:\/\/nhswebsite-dev.nhs.uk\/medicines\//gm,
172+
replaceWithStr: 'href=\\"https://www.nhs.uk/medicines/',
173+
},
135174
{
136175
searchForRegex: /href=\\"\/medicines\//gm,
137176
replaceWithStr: 'href=\\"https://www.nhs.uk/medicines/',
@@ -146,6 +185,11 @@ var searchAndReplaceStrings = [
146185
replaceWithStr:
147186
': "https://' + requestHostnameEnv + "/nhs-website-content/nhs-services/",
148187
},
188+
{
189+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/nhs-services\//gm,
190+
replaceWithStr:
191+
': "https://' + requestHostnameEnv + "/nhs-website-content/nhs-services/",
192+
},
149193
{
150194
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/nhs-services\//gm,
151195
replaceWithStr:
@@ -160,6 +204,10 @@ var searchAndReplaceStrings = [
160204
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/nhs-services\//gm,
161205
replaceWithStr: 'href=\\"https://www.nhs.uk/nhs-services/',
162206
},
207+
{
208+
searchForRegex: /href=\\"https:\/\/nhswebsite-dev.nhs.uk\/nhs-services\//gm,
209+
replaceWithStr: 'href=\\"https://www.nhs.uk/nhs-services/',
210+
},
163211
{
164212
searchForRegex: /href=\\"\/nhs-services\//gm,
165213
replaceWithStr: 'href=\\"https://www.nhs.uk/nhs-services/',
@@ -174,6 +222,11 @@ var searchAndReplaceStrings = [
174222
replaceWithStr:
175223
': "https://' + requestHostnameEnv + "/nhs-website-content/pregnancy/",
176224
},
225+
{
226+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/pregnancy\//gm,
227+
replaceWithStr:
228+
': "https://' + requestHostnameEnv + "/nhs-website-content/pregnancy/",
229+
},
177230
{
178231
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/pregnancy\//gm,
179232
replaceWithStr:
@@ -188,6 +241,10 @@ var searchAndReplaceStrings = [
188241
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/pregnancy\//gm,
189242
replaceWithStr: 'href=\\"https://www.nhs.uk/pregnancy/',
190243
},
244+
{
245+
searchForRegex: /href=\\"https:\/\/nhswebsite-dev.nhs.uk\/pregnancy\//gm,
246+
replaceWithStr: 'href=\\"https://www.nhs.uk/pregnancy/',
247+
},
191248
{
192249
searchForRegex: /href=\\"\/pregnancy\//gm,
193250
replaceWithStr: 'href=\\"https://www.nhs.uk/pregnancy/',
@@ -204,6 +261,13 @@ var searchAndReplaceStrings = [
204261
requestHostnameEnv +
205262
"/nhs-website-content/contraception/",
206263
},
264+
{
265+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/contraception\//gm,
266+
replaceWithStr:
267+
': "https://' +
268+
requestHostnameEnv +
269+
"/nhs-website-content/contraception/",
270+
},
207271
{
208272
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/contraception\//gm,
209273
replaceWithStr:
@@ -222,6 +286,11 @@ var searchAndReplaceStrings = [
222286
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/contraception\//gm,
223287
replaceWithStr: 'href=\\"https://www.nhs.uk/contraception/',
224288
},
289+
{
290+
searchForRegex:
291+
/href=\\"https:\/\/nhswebsite-dev.nhs.uk\/contraception\//gm,
292+
replaceWithStr: 'href=\\"https://www.nhs.uk/contraception/',
293+
},
225294
{
226295
searchForRegex: /href=\\"\/contraception\//gm,
227296
replaceWithStr: 'href=\\"https://www.nhs.uk/contraception/',
@@ -236,6 +305,11 @@ var searchAndReplaceStrings = [
236305
replaceWithStr:
237306
': "https://' + requestHostnameEnv + "/nhs-website-content/vaccinations/",
238307
},
308+
{
309+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/vaccinations\//gm,
310+
replaceWithStr:
311+
': "https://' + requestHostnameEnv + "/nhs-website-content/vaccinations/",
312+
},
239313
{
240314
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/vaccinations\//gm,
241315
replaceWithStr:
@@ -250,6 +324,10 @@ var searchAndReplaceStrings = [
250324
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/vaccinations\//gm,
251325
replaceWithStr: 'href=\\"https://www.nhs.uk/vaccinations/',
252326
},
327+
{
328+
searchForRegex: /href=\\"https:\/\/nhswebsite-dev.nhs.uk\/vaccinations\//gm,
329+
replaceWithStr: 'href=\\"https://www.nhs.uk/vaccinations/',
330+
},
253331
{
254332
searchForRegex: /href=\\"\/vaccinations\//gm,
255333
replaceWithStr: 'href=\\"https://www.nhs.uk/vaccinations/',
@@ -266,6 +344,13 @@ var searchAndReplaceStrings = [
266344
requestHostnameEnv +
267345
"/nhs-website-content/womens-health/",
268346
},
347+
{
348+
searchForRegex: /:\s?"https:\/\/nhswebsite-dev.nhs.uk\/womens-health\//gm,
349+
replaceWithStr:
350+
': "https://' +
351+
requestHostnameEnv +
352+
"/nhs-website-content/womens-health/",
353+
},
269354
{
270355
searchForRegex: /:\s?"https:\/\/www.nhs.uk\/womens-health\//gm,
271356
replaceWithStr:
@@ -284,6 +369,11 @@ var searchAndReplaceStrings = [
284369
searchForRegex: /href=\\"https:\/\/api.nhs.uk\/womens-health\//gm,
285370
replaceWithStr: 'href=\\"https://www.nhs.uk/womens-health/',
286371
},
372+
{
373+
searchForRegex:
374+
/href=\\"https:\/\/nhswebsite-dev.nhs.uk\/womens-health\//gm,
375+
replaceWithStr: 'href=\\"https://www.nhs.uk/womens-health/',
376+
},
287377
{
288378
searchForRegex: /href=\\"\/womens-health\//gm,
289379
replaceWithStr: 'href=\\"https://www.nhs.uk/womens-health/',
@@ -298,6 +388,12 @@ var searchAndReplaceStrings = [
298388
replaceWithStr:
299389
': "https://' + requestHostnameEnv + "/nhs-website-content/manifest/",
300390
},
391+
{
392+
searchForRegex:
393+
/:\s?"https:\/\/nhswebsite-dev.nhs.uk\/content-api\/manifest\//gm,
394+
replaceWithStr:
395+
': "https://' + requestHostnameEnv + "/nhs-website-content/manifest/",
396+
},
301397
{
302398
comment1: "=============================================================",
303399
comment2: "Webpage hostname ",

0 commit comments

Comments
 (0)