Skip to content

Conversation

@cdl
Copy link

@cdl cdl commented Jun 22, 2023

This PR aims to clean up the logic for our redirects.

The main change is a fairly low-risk refactor. Instead of two separate arrays and needing to ensure you don't end up off-by-one, we can instead use a hash and use Object.keys() and Object.values() to compose the resulting arrays.

The second commit updates the redirect logic to instead look at the final segment of the URL to find the ID, instead of looping through every ID and then .indexOf()-ing the URL. This reduces the time complexity of the lookup and should make all redirects equally fast. Right now, later redirects take longer to perform due to looping through the older redirects first.

@cdl cdl force-pushed the refactor-redirects branch from cd3c58c to ad342b6 Compare June 22, 2023 22:43
@cdl cdl force-pushed the refactor-redirects branch from ad342b6 to 24cd2ce Compare June 22, 2023 22:55
@cdl cdl force-pushed the refactor-redirects branch from 9a43f33 to fdda3d0 Compare June 22, 2023 23:08
@cdl
Copy link
Author

cdl commented Jun 22, 2023

We should maybe gate these changes behind a query parameter. This will allow us to deploy this change & confidently validate that the new logic does not regress the existing redirects, before effecting 100% of redirects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants