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

-[NSURL URLByAppendingPathComponent:] only works if URL had a path component to begin with #17

Closed
fay59 opened this issue Dec 8, 2017 · 1 comment

Comments

@fay59
Copy link

fay59 commented Dec 8, 2017

#include <Foundation/Foundation.h>

int main() {
        NSURL* url = [NSURL URLWithString:@"http://www.example.com"];
        NSURL* next = [url URLByAppendingPathComponent:@"example_path"];
        NSLog(@"%@", next);
}

This outputs "http://www.example.com/". Using this base URL instead:

NSURL* url = [NSURL URLWithString:@"http://www.example.com/"];

(notice the trailing forward slash)

then we actually get "http://www.example.com/example_path".

Apple's implementation returns "http://www.example.com/example_path" for both.

@rfm
Copy link
Contributor

rfm commented Jan 3, 2018

Now fixed in the git repository

@rfm rfm closed this as completed Jan 3, 2018
qmfrederik pushed a commit to qmfrederik/libs-base that referenced this issue Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants