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(v2): make correct internal link check #2424

Merged
merged 1 commit into from
Mar 18, 2020

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Mar 18, 2020

Motivation

Make fixes as per comment #2420 (comment) from @38elements.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

See tests.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 added the pr: bug fix This PR fixes a bug in a past release. label Mar 18, 2020
@lex111 lex111 added this to the v2.0.0-alpha.49 milestone Mar 18, 2020
@lex111 lex111 requested a review from yangshun as a code owner March 18, 2020 11:33
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 18, 2020
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 18351c8

https://deploy-preview-2424--docusaurus-2.netlify.com

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

Probably ok to merge but let's talk about the edge case.


describe('isInternalUrl', () => {
test('should be true for root relative links', () => {
expect(isInternalUrl('/foo/bar')).toBeTruthy();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be incorrect in the cases it is a relative link from the root of the domain. For example your site is a www.example.com/website/ and your path is /hello/foo/ which is intended to lead to www.example.com/hello/foo. Maybe we need to compare with the baseUrl to decide if it's an internal link? WDYT?

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 thought about it, but how do we get the base url in this util function? Pass baseUrl as an argument? Hmm, I don’t know, it seems to me then users need to only use relative links for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can read the baseUrl from the config, so users don't have to pass it in. Maybe check if the string values starts with baseUrl? Not sure too.

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 would prefer to leave it as it is, if in the future users encounter such a case, then we will try to solve it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

@yangshun yangshun merged commit 2fd50f9 into master Mar 18, 2020
@yangshun yangshun deleted the lex111/fix-internal-link-check-fun branch March 21, 2020 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants