-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make an allow list of deep linkable routes #158
Conversation
Library/Navigation.swift
Outdated
@@ -260,6 +267,33 @@ private let routes: [String:(RouteParams) -> Decoded<Navigation>] = [ | |||
"/users/:user_param/surveys/:survey_response_id": userSurvey | |||
] | |||
|
|||
private let deepLinkRoutes: [String:(RouteParams) -> Decoded<Navigation>] = allRoutes.allValues( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the allow-list of routes we'll use for deep linking. I'm using this lil private helper Dictionary.allValues(from:)
to pluck out a certain set of keys from the allRoutes
dictionary.
open to other names!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh actually, using Hoogle I found this function:
restrictKeys :: Ord k => Map k a -> Set k -> Map k a
which is a better name and a better definition! maybe we should even add this to the prelude...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one suggestion for future-proofing, but approving anyway.
"/projects/:creator_param/:project_param/posts/:update_param/comments", | ||
"/projects/:creator_param/:project_param/surveys/:survey_param", | ||
"/users/:user_param/surveys/:survey_response_id" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! only suggestion would be to put these keys into an enum since a string could potentially change in one of these places and not the other.
Right now our routing systems has a big ole list of URLs on Kickstarter that we want to recognize in a variety of situations, e.g. when inspecting requests in a web view, and when deep linking into the app.
Sometimes we want to use a different set of recognizable routes depending on the situation we are routing. In particular, when deep linking there is a smaller set of routes we want to recognize, and then anything we don't recognize can bump the user back to mobile safari.
That's what this PR does...
There are smarter ways to do this, and would love to try it out soon, but this will do the job and is well tested!