Introduce QR Code Shortlink Redirect Handling #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We have a desire to publish QR codes on signs around South Lake Tahoe, with values like:
These will map to different specific locations around town, to be determined.
Solution
/qr
route, so that GET requests tomap.tahoebike.org/qr/:qrId
are explicitly handled.qrId
matches one of the pre-determined options, redirect to the specified URL. Else fall back to the index url.polyline.decode
an empty path. I put this behind a conditional, and if the path is empty just manually populated the path with the start and end points.<Elevation>
component did not nicely handle an array of elevation values with zero length, and in JS!!emptyArray
evaluates totrue
, so the logic to conditionally render the component was missing this. I coerced the elevations array to its initial value ofnull
if it comes back empty, and now!!null
isfalse
and so the component isn't rendered.Testing
Ran the app locally and navigated to the following URLs, observing results:
Matches
A matching URL redirects as expected:
localhost:3000/qr/1
Fallthroughs
The following URLs redirected to the main index page:
localhost:3000/qr
localhost:3000/qr/99
localhost:3000/qr/foo