hof 21.2.0-postcode-lookup-beta.3 → 21.2.0-postcode-lookup-beta.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
|
|
1
|
-
/* eslint-disable func-names */
|
1
|
+
/* eslint-disable func-names, max-len */
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const path = require('path');
|
@@ -222,7 +222,7 @@ module.exports = config => {
|
|
222
222
|
locals(req, res, callback) {
|
223
223
|
const isManualStep = req.query.step === 'manual';
|
224
224
|
const locals = super.locals(req, res, callback);
|
225
|
-
const sessionPostcode = req.sessionModel.get(`${addressFieldNamePrefix}-postcode`)?.replace(/[^\w]+/g,
|
225
|
+
const sessionPostcode = req.sessionModel.get(`${addressFieldNamePrefix}-postcode`)?.replace(/[^\w]+/g, '').replace(/^(.*)(\d)/, '$1 $2');
|
226
226
|
const section = this.options.route.replace(/^\//, '');
|
227
227
|
const editLink = conditionalTranslate('pages.address-lookup.edit', req.translate) || defaults.CHANGE;
|
228
228
|
const searchByPostcodeLink = conditionalTranslate('pages.address.searchByPostcode', req.translate) ||
|
@@ -279,7 +279,7 @@ module.exports = config => {
|
|
279
279
|
// Clear the value stored in the addresses radio button group
|
280
280
|
req.sessionModel.set(`${addressFieldNamePrefix}-select`, '');
|
281
281
|
// Replace punctuation in postcode and call OS Places API to return list of addresses
|
282
|
-
const enteredPostcode = req.form.values[`${addressFieldNamePrefix}-postcode`]?.replace(/[^\w]+/g,
|
282
|
+
const enteredPostcode = req.form.values[`${addressFieldNamePrefix}-postcode`]?.replace(/[^\w]+/g, '').replace(/^(.*)(\d)/, '$1 $2');
|
283
283
|
|
284
284
|
await PostcodeLookup(enteredPostcode, apiURL, apiKey)
|
285
285
|
.then(function (response) {
|
@@ -343,7 +343,7 @@ module.exports = config => {
|
|
343
343
|
saveValues(req, res, callback) {
|
344
344
|
const step = req.query.step;
|
345
345
|
if (step === 'postcode') {
|
346
|
-
postcode = req.form.values[`${addressFieldNamePrefix}-postcode`]?.replace(/[^\w]+/g,
|
346
|
+
postcode = req.form.values[`${addressFieldNamePrefix}-postcode`]?.replace(/[^\w]+/g, '$1 $2');
|
347
347
|
this.clearAddressFieldValues(req);
|
348
348
|
return this.postcode(req, res, err => {
|
349
349
|
if (err) {
|
@@ -180,7 +180,7 @@ module.exports = Validators = {
|
|
180
180
|
|
181
181
|
postcodeValidation(value) {
|
182
182
|
// eslint-disable-next-line max-len
|
183
|
-
return Validators.regex(value, /^(([GIRgir] ?[ ]*0[ ]*[Aa]{2}[ ]*)|((([A-Za-z][ ]*[0-9]{1,2}[ ]*)|(([A-Za-z][ ]*[A-Ha-hJ-Yj-y][ ]*[0-9][ ]*[0-9]?)[ ]*|(([A-Za-z][ ]*[0-9][ ]*[A-Za-z][ ]*)|([A-Za-z][ ]*[A-Ha-hJ-Yj-y][ ]*[0-9]?[ ]*[A-Za-z][ ]*))))[^\w]
|
183
|
+
return Validators.regex(value, /^(([GIRgir] ?[ ]*0[ ]*[Aa]{2}[ ]*)|((([A-Za-z][ ]*[0-9]{1,2}[ ]*)|(([A-Za-z][ ]*[A-Ha-hJ-Yj-y][ ]*[0-9][ ]*[0-9]?)[ ]*|(([A-Za-z][ ]*[0-9][ ]*[A-Za-z][ ]*)|([A-Za-z][ ]*[A-Ha-hJ-Yj-y][ ]*[0-9]?[ ]*[A-Za-z][ ]*))))[^\w]*?[ ]*[0-9][ ]*[A-Za-z][ ]*[A-Za-z][ ]*))$/);
|
184
184
|
}
|
185
185
|
|
186
186
|
};
|
package/package.json
CHANGED
package/.vscode/settings.json
DELETED