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

Issue-89 - Add support for arrays in query parameters #98

Closed
wants to merge 7 commits into from

Conversation

pavelpantus
Copy link
Contributor

Possible solution if I got the meaning right.

Removes array literal ('[]') from the string
@return String without array literal ('[]')
*/
- (NSString *)DPL_removeArrayLiteral;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convention would indicate:
DPL_stringByRemovingArrayLiteral or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing, will correct it shortly.

On Thursday, April 7, 2016, Chris Maddern [email protected] wrote:

In DeepLinkKit/Categories/NSString+DPLQuery.h
#98 (comment):

+- (BOOL)DPL_containsArrayLiteral;
+
+
+/**

  • Checks if string contains key with array literal
  • @return YES if string contains key with '[]' attached (e.g. "key[]"),
  •      NO otherwise (e.g. "key")
    
  • /
    +- (BOOL)DPL_containsArrayLiteralWithKey:(NSString *)key;
    +
    +
    +/
    *
  • Removes array literal ('[]') from the string
  • @return String without array literal ('[]')
  • */
    +- (NSString *)DPL_removeArrayLiteral;

Convention would indicate:
DPL_stringByRemovingArrayLiteral or something similar


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/button/DeepLinkKit/pull/98/files/7cebc8717560a0a64fb675df53f041ef2e2d7acb#r58930895

Best regards,
Pavel Pantus

@pavelpantus
Copy link
Contributor Author

That's really cool test failure:
expected: beers[]=stout&beers[]=ale&liquors[]=vodka&liquors[]=whiskey
got: liquors[]=vodka&liquors[]=whiskey&beers[]=stout&beers[]=ale

(Different ordering in NSDictionary)

Test passes on my machine though :)

@@ -74,4 +75,14 @@ - (DPLDemoAction *)logHelloWorldAction {
return action;
}


- (DPLDemoAction *)logShoppingList {
DPLMutableDeepLink *link = [[DPLMutableDeepLink alloc] initWithString:@"dpl://shoppinglist?list%5B%5D%3DBread&list%5B%5D%3DCandies&list%5B%5D%3DWine&list%5B%5D%3DBeer"];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if here should be easier way to initialize deep link with URLs of such kind?

@pavelpantus
Copy link
Contributor Author

@wessmith @chrismaddern Hey guys, wanted to ask for your feedback.
Is it the right direction or I missed something important here? Thanks!

@wessmith
Copy link
Member

wessmith commented Apr 8, 2016

Hi @pantuspavel this is looking good 😄 but I haven't had a chance to fully go through it.

NSString *queryStringToMatch;
NSString *queryStringPartBeers = @"beers[]=stout&beers[]=ale";
NSString *queryStringPartLiquors = @"liquors[]=vodka&liquors[]=whiskey";
if ([[params allKeys][0] isEqualToString:@"beers"]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably have a suitable default here such as ordered ascending that way we can expect a consistent result.

Similarly, when parsing a url, I would expect to have the parameter order preserved so re-serialization mirrors the original url though that can't really happen in the category (#15) without more information.

For example:

NSURL *url = [NSURL URLWithString:@"dpl://something/?liquors[]=vodka&liquors[]=whiskey&beers[]=stout&beers[]=ale"];
DPLDeepLink *link = [[DPLDeepLink alloc] initWithURL:url];
link.URL.query  // should serialize as => @"liquors[]=vodka&liquors[]=whiskey&beers[]=stout&beers[]=ale"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wessmith Just making sure I understand that correctly: you are talking here about DPLMutableDeepLink not DPLDeepLinkright? (DPLDeepLink returns previously set URL without any serialization work).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Yeah.

@pavelpantus
Copy link
Contributor Author

Hey @wessmith,
That definitely makes sense! I'll make this happen.
Thanks and sorry for pushing, was very curious to get your feedback! 😄

@wessmith
Copy link
Member

wessmith commented Apr 8, 2016

@pantuspavel If you want to tackle #15 I'd love to hear your thoughts on how you would approach it before you get too far into it :)

@pavelpantus
Copy link
Contributor Author

@wessmith sure,
I'm thinking to sort parameters first and then serialize them in:

[NSString DPL_queryStringWithParameters:(NSDictionary *)parameters];

This way we always get the same order in the output string.

@wessmith
Copy link
Member

wessmith commented Apr 8, 2016

That works. Then we can tackle #15 later.

@pavelpantus
Copy link
Contributor Author

@wessmith ooh, I just got what #15 is about.
Yeah, you're right. We'll need more info here.
I'll think about solution, but first will commit the consistent ordering.

@pavelpantus
Copy link
Contributor Author

What do you think of using some kind of ordered dictionary(e.g. M13OrderedDictionary - not sure about this one though. Last commit - Oct. 2015)

@wessmith
Copy link
Member

wessmith commented Apr 8, 2016

We don't want to add any dependencies. Perhaps we pass in an NSArray or NSOrderedSet of sorted keys to an overloaded [NSString DPL_queryStringWithParameters:sortedKeys:]

@pavelpantus
Copy link
Contributor Author

Yeah, that was my second thought -- dependencies.
Your solution sounds good to me.
Thanks for the idea.

On Friday, April 8, 2016, Wes Smith [email protected] wrote:

We don't want to add any dependencies. Perhaps we pass in an NSArray or
NSOrderedSet of sorted keys to an overloaded [NSString
DPL_queryStringWithParameters:sortedKeys:]


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#98 (comment)

Best regards,
Pavel Pantus

@lucasecf
Copy link

Hey guys, any plan to merge this?

@chrismaddern
Copy link
Contributor

@wessmith @pantuspavel what's the action here? Would love to get this merged!

@wessmith
Copy link
Member

@pantuspavel can you have a look at this and make sure its up to date and all comments are resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants