Skip to content

Normalise postcodes #2044

@symroe

Description

@symroe

When we get a postcode from a user it can take some different forms:

  1. With or without space
  2. Caps or no caps
  3. Any combination of the above

This is a problem in a few ways:

  • The postcode result pages uses the user-entered variation of the postcode in the UK. e.g, URLs with and without spaces both work
  • The logging client accepts the user entered postcode

This causes downstream problems with caching and querying logs. Not having a canonical URL for a postcode might cause undercounts in analytics.

In both of these case we validate that the postcode is valid before showing a URL or logging it, but we don't normalise it.

In other projects we have a Postcode class that can normalise user-provided data into a single form.

We should implement that here (or add that class to DC utils) and convert string postcodes to that early on in the process. We can then use a Postcode class for URLs, logging, etc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions