Route pattern matching
jknthn opened this issue · comments
Hi, first of all your library is great and now we are using it in second project, and we are more than happy.
But I have first problem, and I would like you to ask if I am doing something wrong or this type of route is not possible.
I have several deep links that look like application://something?somethingElse=value
and i wanted to handle route like ":type?:parameter"
, and extract value by using query.parameters
. But this block never gets called. It is ok when I do something?:parameters
something2:parameters
...
but it is quite too much code in my opinion.
Hey @jknthn - I think you can achieve this as follows.. I added a test to verify: https://github.com/usebutton/DeepLinkKit/pull/82/files
Anything before the first /
is considered the host and DLK supports named groups for anything after the scheme. So.. the DLK matcher :host
will match any host and the parameters will be extracted into the queryParmeters
array.
self.router[@":host"] = ^(DPLDeepLink *deepLink) {
NSString *host = deepLink.routeParameters[@"host"];
// deepLink.queryParameters will contain all your parameters for free.
};
Closing since it looks like we have a solution for this.
@wessmith @chrismaddern Sorry for not answering. Your solution as all right, and it worked :) I was trying to figure out something more safe and specific but it ended like that. Thanks.