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

Make an allow list of deep linkable routes #158

Merged
merged 5 commits into from
May 18, 2017
Merged

Conversation

mbrandonw
Copy link
Contributor

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!

@@ -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(
Copy link
Contributor Author

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!

Copy link
Contributor Author

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...

Copy link
Contributor

@theginbin theginbin left a 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"
]
Copy link
Contributor

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.

@mbrandonw mbrandonw merged commit 141fa9c into master May 18, 2017
@mbrandonw mbrandonw deleted the skip-some-deep-links branch May 18, 2017 13:49
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.

None yet

2 participants