diff --git a/DeepLinkKit/DeepLink/DPLDeepLink.m b/DeepLinkKit/DeepLink/DPLDeepLink.m index ec804c1..c0ad723 100644 --- a/DeepLinkKit/DeepLink/DPLDeepLink.m +++ b/DeepLinkKit/DeepLink/DPLDeepLink.m @@ -106,14 +106,18 @@ - (NSUInteger)hash { #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone { - return [[[self class] alloc] initWithURL:self.URL]; + DPLDeepLink *copiedLink = [[[self class] alloc] initWithURL:self.URL]; + copiedLink.routeParameters = self.routeParameters; + return copiedLink; } #pragma mark - NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone { - return [[DPLMutableDeepLink alloc] initWithString:self.URL.absoluteString]; + DPLMutableDeepLink *copiedLink = [[DPLMutableDeepLink alloc] initWithString:self.URL.absoluteString]; + copiedLink.routeParameters = self.routeParameters; + return copiedLink; } diff --git a/DeepLinkKit/DeepLink/DPLMutableDeepLink.m b/DeepLinkKit/DeepLink/DPLMutableDeepLink.m index 5028496..16ecf6c 100644 --- a/DeepLinkKit/DeepLink/DPLMutableDeepLink.m +++ b/DeepLinkKit/DeepLink/DPLMutableDeepLink.m @@ -88,14 +88,18 @@ - (id)forwardingTargetForSelector:(SEL)aSelector { #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone { - return [[DPLDeepLink alloc] initWithURL:self.URL]; + DPLDeepLink *copiedLink = [[DPLDeepLink alloc] initWithURL:self.URL]; + copiedLink.routeParameters = self.routeParameters; + return copiedLink; } #pragma mark - NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone { - return [[[self class] alloc] initWithString:self.URL.absoluteString]; + DPLMutableDeepLink *copiedLink = [[[self class] alloc] initWithString:self.URL.absoluteString]; + copiedLink.routeParameters = self.routeParameters; + return copiedLink; } @end diff --git a/Podfile.lock b/Podfile.lock index 3d52d52..8a892b5 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -19,7 +19,7 @@ EXTERNAL SOURCES: :path: . SPEC CHECKSUMS: - DeepLinkKit: 5349fa5cc37cadeb32e0fa239c28536bc0557cf2 + DeepLinkKit: c5c1b216b8aa00fa7735ffeee6a354e39e7574ac Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe KIF: 2275c6d59c77e5e56f660f006b99d73780130540 OCMock: 18c9b7e67d4c2770e95bb77a9cc1ae0c91fe3835 diff --git a/Tests/DeepLink/DPLDeepLinkSpec.m b/Tests/DeepLink/DPLDeepLinkSpec.m index 6ad33fd..1f1f85d 100644 --- a/Tests/DeepLink/DPLDeepLinkSpec.m +++ b/Tests/DeepLink/DPLDeepLinkSpec.m @@ -61,9 +61,17 @@ DPLDeepLink *link2 = [link1 copy]; expect(link2).toNot.beNil(); - expect(link1.URL).to.equal(link2.URL); - expect(link1.queryParameters).to.equal(link2.queryParameters); - expect(link1.callbackURL).to.equal(link2.callbackURL); + expect(link2.URL).to.equal(link1.URL); + expect(link2.queryParameters).to.equal(link1.queryParameters); + expect(link2.routeParameters).to.equal(link1.routeParameters); + expect(link2.callbackURL).to.equal(link1.callbackURL); + }); + + it(@"immutable copy includes route parameters", ^{ + DPLDeepLink *link1 = [[DPLDeepLink alloc] initWithURL:url]; + link1.routeParameters = @{ @"type": @"ride" }; + DPLDeepLink *link2 = [link1 copy]; + expect(link2.routeParameters).to.equal(link1.routeParameters); }); it(@"returns a mutable deep link via mutable copy", ^{ @@ -75,8 +83,16 @@ expect(mutableLink.host).to.equal(@"dpl.io"); expect(mutableLink.path).to.equal(@"/ride/abc123"); expect(mutableLink.queryParameters).to.equal(link.queryParameters); + expect(mutableLink.routeParameters).to.equal(link.routeParameters); expect(mutableLink.URL).to.equal(link.URL); }); + + it(@"mutable copy includes route parameters", ^{ + DPLDeepLink *link = [[DPLDeepLink alloc] initWithURL:url]; + link.routeParameters = @{ @"type": @"ride" }; + DPLMutableDeepLink *mutableLink = [link mutableCopy]; + expect(mutableLink.routeParameters).to.equal(link.routeParameters); + }); }); diff --git a/Tests/DeepLink/DPLMutableDeepLinkSpec.m b/Tests/DeepLink/DPLMutableDeepLinkSpec.m index 38ab14f..9c8e4d0 100644 --- a/Tests/DeepLink/DPLMutableDeepLinkSpec.m +++ b/Tests/DeepLink/DPLMutableDeepLinkSpec.m @@ -124,17 +124,33 @@ expect(link.callbackURL.absoluteString).to.equal(@"dpl://back"); }); + it(@"immutable copy includes route parameters", ^{ + NSString *URLString = @"dpl://dpl.com/here?foo=bar&dpl_callback_url=dpl://back"; + DPLMutableDeepLink *mutableLink = [[DPLMutableDeepLink alloc] initWithString:URLString]; + mutableLink.routeParameters = @{ @"where": @"here" }; + DPLDeepLink *link = [mutableLink copy]; + expect(link.routeParameters).to.equal(mutableLink.routeParameters); + }); + it(@"returns a mutable deep link via mutableCopy", ^{ NSString *URLString = @"dpl://dpl.com/here?foo=bar&dpl_callback_url=dpl://back"; DPLMutableDeepLink *link1 = [[DPLMutableDeepLink alloc] initWithString:URLString]; DPLMutableDeepLink *link2 = [link1 mutableCopy]; expect(link2).toNot.beNil(); - expect(link1.scheme).to.equal(link2.scheme); - expect(link1.host).to.equal(link2.host); - expect(link1.path).to.equal(link2.path); - expect(link1.queryParameters).to.equal(link2.queryParameters); - expect(link1.URL).to.equal(link2.URL); + expect(link2.scheme).to.equal(link1.scheme); + expect(link2.host).to.equal(link1.host); + expect(link2.path).to.equal(link1.path); + expect(link2.queryParameters).to.equal(link1.queryParameters); + expect(link2.URL).to.equal(link1.URL); + }); + + it(@"mutable copy includes route parameters", ^{ + NSString *URLString = @"dpl://dpl.com/here?foo=bar&dpl_callback_url=dpl://back"; + DPLMutableDeepLink *mutableLink = [[DPLMutableDeepLink alloc] initWithString:URLString]; + mutableLink.routeParameters = @{ @"where": @"here" }; + DPLDeepLink *link = [mutableLink mutableCopy]; + expect(link.routeParameters).to.equal(mutableLink.routeParameters); }); });