DoSomething / bertly

🔗 A serverless link shortener.
https://dosome.click/wq544
MIT License
2 stars 1 forks source link

Normalize URLs before querying/saving. #75

Closed DFurnes closed 4 years ago

DFurnes commented 4 years ago

What's this PR do?

This pull request adds a mutator to the url field to ensure we've normalized the URL before we save it to the database. This is a follow-up from https://github.com/DoSomething/bertly/pull/74#discussion_r435407693 that I'd like to merge in before we run the backfill (since some links will be re-normalized differently).

How should this be reviewed?

👀

Any background context you want to provide?

This uses the normalize-url package. It uses slightly different normalization rules than the url-normalize package we'd been using in Python.

In particular, we now trim trailing /s when possible & sort and URL-encode query parameters. (This should not have any impact on applications or metrics, but wanted to flag!)

Relevant tickets

References Pivotal #165507221.

Checklist