Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce QR Code Shortlink Redirect Handling #49

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

nickspeal
Copy link
Collaborator

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

  • Implement a new /qr route, so that GET requests to map.tahoebike.org/qr/:qrId are explicitly handled.
  • If the qrId matches one of the pre-determined options, redirect to the specified URL. Else fall back to the index url.
  • I picked "pin points" on the map by looking up directions from one point to the same point. The UX of this can be improved in the future, but I like it for now as a proof of concept for the QR codes feature. I populated the mapping with a handful of URLs like this, anticipating that many more will be added later.
  • I noticed and corrected several issues when the start and end point are the same for a route:
    • The code crashed when trying to 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.
    • The <Elevation> component did not nicely handle an array of elevation values with zero length, and in JS !!emptyArray evaluates to true, so the logic to conditionally render the component was missing this. I coerced the elevations array to its initial value of null if it comes back empty, and now !!null is false 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
Screen Shot 2024-11-20 at 6 00 50 PM

Fallthroughs

The following URLs redirected to the main index page:

  • localhost:3000/qr
  • localhost:3000/qr/99
  • localhost:3000/qr/foo

@nickspeal
Copy link
Collaborator Author

Example QR Code
hovercode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants