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

myapp://web/:URLString doesn't work #43

Closed
aelam opened this issue Jun 12, 2014 · 13 comments
Closed

myapp://web/:URLString doesn't work #43

aelam opened this issue Jun 12, 2014 · 13 comments

Comments

@aelam
Copy link

aelam commented Jun 12, 2014

I defiend myapp://web/:URLString
URLString will be URLencoded before,
it would be myapp://web/http%3A%2F%2Fbaidu.com
but it's broken in pathComponents parsing. The encoded url would be split.
See your code, pathComponents would be web, http:, baidu.com

JLRoutes.m line:370
    // break the URL down into path components and filter out any leading/trailing slashes from it
    NSArray *pathComponents = [(URL.pathComponents ?: @[]) filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT SELF like '/'"]];

    if ([URL.host rangeOfString:@"."].location == NSNotFound) {
        // For backward compatibility, handle scheme://path/to/ressource as if path was part of the
        // path if it doesn't look like a domain name (no dot in it)
        pathComponents = [@[URL.host] arrayByAddingObjectsFromArray:pathComponents];
}

Do you have an official way in your mind of this ?

@isaaclimdc
Copy link

This is also the case for me! A fix for this would be great!

@aelam
Copy link
Author

aelam commented Jul 24, 2014

maybe base64 can fix this, but I don't think it's the best way

Sent from my iPhone

On Jul 23, 2014, at 7:54 AM, Isaac Lim notifications@github.com wrote:

This is also the case for me! A fix for this would be great!


Reply to this email directly or view it on GitHub.

@joeldev
Copy link
Owner

joeldev commented Jul 24, 2014

It seems that NSURL pathComponent parsing doesn't like this. Is it possibly to simply not have "http://" as part of the URL? I could make a special case for http(s), but that seems dirty. I'll have to ponder this one a bit.

@kylebshr
Copy link

+1 for passing URLs

@aelam
Copy link
Author

aelam commented Sep 28, 2015

In the end. I change to Web?url=encodedUrl(). It can work

@btxkenshin
Copy link

@aelam what does this mean?
At first,you said:

I defiend myapp://web/:URLString
URLString will be URLencoded before,
it would be myapp://web/http%3A%2F%2Fbaidu.com

So,what do you mean by change to Web?url=encodedUrl(),need help really

@aelam
Copy link
Author

aelam commented Jan 4, 2016

I mean it can't be parsed correctly in the pattern of myapp://web/:encodedURLString
But if you modify it to myapp://web?url=encodedURLString. it does

@btxkenshin
Copy link

got it,It seems better to manual modify the parser logic

Thanks!

@btxkenshin
Copy link

@aelam got a new problem
if the encodedURLString is something like http://xxx.xxx?aa=xx&bb=xx, then you will never get the correct url,for example

[JLRoutes addRoute:@"/web/rich/*" handler:^BOOL(NSDictionary *parameters) {
        NSString *url = parameters[@"url"];
       //do the navigation
    }];

Instead, you will get parameters url,aa,bb...

@aelam
Copy link
Author

aelam commented Jan 5, 2016

encodedURLString means the url string should be encoded
You didn't

发自我的 iPhone

在 2016年1月5日,下午9:04,btxkenshin notifications@github.com 写道:

@aelam got a new problem
if the encodedURLString is somethin like http://xxx.xxx?aa=xx&bb=xx, then you will never get the correct url,for example

[JLRoutes addRoute:@"/web/rich/*" handler:^BOOL(NSDictionary *parameters) {
NSString *url = parameters[@"url"];
//do the navigation
}];
Instead, you will get parameters url,aa,bb...


Reply to this email directly or view it on GitHub.

@btxkenshin
Copy link

Do you ever have a try?or,it must be something missing?

It seems that the character: & will not be encoded, so the JLRoutes will parse these & into extern key-value parmaters.

Any way , i modify the parser, manuly parse the pathComponents instead of the default URL. pathComponents to handle this.

@aelam
Copy link
Author

aelam commented Jan 7, 2016

Firstly, encode

http://www.baidu.com?a=b&c=d

It should be
http%3a%2f%2fwww.baidu.com%3fa%3db%26c%3dd

Otherwise, your code of urlencode is wrong
Try 'pod search urlencode
Use the first one

Be attention.
Encode the whole url (including the query part)
And then try
Your-scheme://web?url=xxx

Sent from my iPhone

On Jan 7, 2016, at 12:32 PM, btxkenshin notifications@github.com wrote:

Do you ever have a try?or,it must be something missing?

It seems that the character: & will not be encoded, so the JLRoutes will parse these & into extern key-value parmaters.

Any way , i modify the parser, manuly parse the pathComponents instead of the default URL. pathComponents to handle this.


Reply to this email directly or view it on GitHub.

@aelam
Copy link
Author

aelam commented Oct 11, 2016

Great!

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

No branches or pull requests

5 participants