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

fix: h5页面请求url为相对路径时,url的拼接问题。 #20

Merged
merged 1 commit into from
Jun 16, 2020

Conversation

tyrad
Copy link
Contributor

@tyrad tyrad commented Jun 15, 2020

作者您好,h5页面请求url为相对路径时,测试发现地址拼接处的代码有误:

 url = [[href stringByAppendingPathComponent:url] stringByStandardizingPath];

实际并不会按照期望的规则进行拼接,建议改成NSURL的拼接方式:

NSURL *newUrl = [NSURL URLWithString:url relativeToURL:[NSURL URLWithString:href]];

 NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithURL:newUrl resolvingAgainstBaseURL:YES];
// 清除h5页面的参数
urlComponents.query = nil;
url = urlComponents.string;

@karosLi
Copy link
Owner

karosLi commented Jun 16, 2020

嗯,多谢你的PR。关于参数的话,还是最好不要清空了。

// 清除h5页面的参数
urlComponents.query = nil;

@karosLi karosLi merged commit fadc114 into karosLi:master Jun 16, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants