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: resolve markdown links to handle relative URLs #358

Merged
merged 5 commits into from
Jan 28, 2019

Conversation

ltm
Copy link
Contributor

@ltm ltm commented Jan 26, 2019

No description provided.

@ltm ltm requested a review from camwiegert January 26, 2019 18:23
@camwiegert
Copy link
Contributor

Looking at the way that GitHub resolves links in a README, they seem to resolve all base paths as if they were a directory.

githubResolve('/some/path', '../other-path') => '/some/other-path'
githubResolve('/some/path/', '../other-path') => '/some/other-path'

Whereas Node's plain url.resolve would handle it like this:

url.resolve('/some/path', '../other-path') => '/other-path'
url.resolve('/some/path/', '../other-path') => '/some/other-path'

So I think we should handle it like GitHub and append a trailing slash during resolution if there isn't one.

resolve(/\/$/.test(basePath) ? basePath : `${basePath}/`, href)

Does that make sense?

@ltm
Copy link
Contributor Author

ltm commented Jan 28, 2019

@camwiegert I was achieving that with the trailing slash here:

const baseUrl = `/docs/api/${title.slice(4)}/`;

But it looks like that got lost in the merge.

@camwiegert
Copy link
Contributor

@ltm Oh, I see. I think I'd rather move that into the link renderer so that it will apply to every link instead of just the API pages.

@ltm
Copy link
Contributor Author

ltm commented Jan 28, 2019

@camwiegert 👍

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.

2 participants