button / DeepLinkKit

A splendid route-matching, block-based way to handle your deep links.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Have optionnal parameter

opened this issue · comments

Hi,

I would like to track a campaign code in the deep link to see where some of the users come from.
So I can have something like @"/account" but also @"/account/:campaign_code".
It would be nice to do that !

We don't currently support regex matching on the URL as a whole, only individual path components. Sounds like a good idea though. For now, you could register two handlers with the more specific route first.

router[@"/account/:campaign_code"] = ^(DPLDeepLink *link) {
    // run some code
};

router[@"/account"] = ^(DPLDeepLink *link) {
    // run some code
};

Or even:

void (^accountHandler)(DPLDeepLink *) = ^(DPLDeepLink *link) {
    // run some code
};
router[@"/account/:campaign_code"] = accountHandler;
router[@"/account"] = accountHandler;

Closing as duplicate of #63