You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using 1.2.1, I’m noticing an issue with routes that consist of a single path component failing to be handled when a trailing slash is included in the URL. This issue is not present when there is more than one path component in the registered route.
Example
In Info.plist, I have the following scheme, test, set up so that my test app opens from Mobile Safari for URLs that begin with test://.
This is the entirety of AppDelegate.m in an otherwise empty test project, in which I demonstrate the issue:
#import"AppDelegate.h"
#import<DeepLinkKit/DeepLinkKit.h>@interfaceAppDelegate ()
@property (nonatomic) DPLDeepLinkRouter *router;
@end@implementationAppDelegate
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.router = [[DPLDeepLinkRouter alloc] init];
self.router[@"search"] = ^(DPLDeepLink *link) {
// Called for `test://search`// Not called for `test://search/` <-- THE ISSUENSLog(@"Handled Search Link");
};
self.router[@"settings/about"] = ^(DPLDeepLink *link) {
// Called for `test://settings/about`// Called for `test://settings/about/`NSLog(@"Handled settings/about Link");
};
returnYES;
}
- (BOOL)application:(UIApplication *)applicationopenURL:(NSURL *)urlsourceApplication:(NSString *)sourceApplicationannotation:(id)annotation {
return [self.router handleURL:url withCompletion:NULL];
}
@end
In summary, the issue shown in this example is that when attempting to open test://search/ in Mobile Safari the handler that logs the message "Handled Search Link" is not called.
Workaround
There is a workaround to the issue, and that is to specify /? to the end of the registered route to allow for an optional trailing slash. In the example above, that’d change the registration of search to be:
self.router[@"search/?"] = ^(DPLDeepLink *link) {
// Called for `test://search`// Called for `test://search/`NSLog(@"Handled Search Link");
};
However, this is not ideal as it requires treating routes with different numbers of components differently.
The text was updated successfully, but these errors were encountered:
Using
1.2.1
, I’m noticing an issue with routes that consist of a single path component failing to be handled when a trailing slash is included in the URL. This issue is not present when there is more than one path component in the registered route.Example
In
Info.plist
, I have the following scheme,test
, set up so that my test app opens from Mobile Safari for URLs that begin withtest://
.This is the entirety of
AppDelegate.m
in an otherwise empty test project, in which I demonstrate the issue:In summary, the issue shown in this example is that when attempting to open
test://search/
in Mobile Safari the handler that logs the message "Handled Search Link" is not called.Workaround
There is a workaround to the issue, and that is to specify
/?
to the end of the registered route to allow for an optional trailing slash. In the example above, that’d change the registration ofsearch
to be:However, this is not ideal as it requires treating routes with different numbers of components differently.
The text was updated successfully, but these errors were encountered: