Skip to content

Commit

Permalink
Preserve spaces in postcodes
Browse files Browse the repository at this point in the history
Bing can handle most full postcodes with or without spaces between
the outcode and incode but some (?all) double digit outcodes seem
to present a problem (e.g. DE12 8EA vs DE128EA)
  • Loading branch information
neilbmclaughlin committed Dec 23, 2024
1 parent 4af395a commit da5f8db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/services/lib/bing-results-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async function bingResultsParser (bingData) {
} = data

const name = ['postcode1', 'postcode3'].includes(data.entityType.toLowerCase())
? data.address.postalCode.replace(/\s/g, '')
? data.address.postalCode
: formatName(data.name)

// Reverse as Bing returns as [y (lat), x (long)]
Expand Down
2 changes: 1 addition & 1 deletion test/services/lib/bing-results-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ experiment('bingResultsParser', () => {

const expectedResult = [
{
name: 'HG50JL',
name: 'HG5 0JL',
center: [-1.46519089, 54.00955582],
bbox2k: [
-1.5045644526149113,
Expand Down

0 comments on commit da5f8db

Please sign in to comment.