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

bug(v2): href links in Footer append a leading slash to mailto: links #2568

Closed
xgp opened this issue Apr 9, 2020 · 2 comments · Fixed by #2579
Closed

bug(v2): href links in Footer append a leading slash to mailto: links #2568

xgp opened this issue Apr 9, 2020 · 2 comments · Fixed by #2579
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@xgp
Copy link

xgp commented Apr 9, 2020

🐛 Bug Report

Using the preset-classic theme, when you add a link to the footer element of the themeConfig using an href, it automatically appends a leading slash if the content of the href doesn't start with an http. This breaks mailto: links.

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

  1. Follow installation instructions to install docusaurus v2 with the classic theme. E.g. npx @docusaurus/init@next init my-website classic
  2. Edit the generated docusaurus.config.js to include a mailto: link in the footer element of the themeConfig. E.g.
module.exports = {
  ...
  themeConfig: {
    footer: {
      style: 'dark',
      links: [
        {
          title: 'Demo',
          items: [
	    {
	      label: 'foo@bar.com',
	      href: 'mailto:foo@bar.com'
	    }
          ],
        },
      ],
      copyright: `Copyright © ${new Date().getFullYear()} Bar, Inc.`,
    },
  1. Run yarn start and click on the foo@bar.com link in the footer

Expected behavior

When clicking the foo@bar.com link, I expected it to open a mail app.

Actual Behavior

It actually tries to open http://<root_url>/mailto:foo@bar.com.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.50
  • Environment name and version:
    • Chrome version 80.0.3987.163 (Official Build) (64-bit)
    • node v13.12.0
  • Operating system and version (desktop or mobile):
    • MacOS Catalina 10.15.4
@xgp xgp added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 9, 2020
@yangshun yangshun changed the title href links in Footer append a leading slash to mailto: links bug(v2): href links in Footer append a leading slash to mailto: links Apr 10, 2020
@yangshun yangshun added difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR. and removed status: needs triage This issue has not been triaged by maintainers labels Apr 10, 2020
@yangshun
Copy link
Contributor

yangshun commented Apr 10, 2020

Indeed, we failed to account for such a use case and assumed all href values are browser URLs.

@xgp
Copy link
Author

xgp commented Apr 10, 2020

Thanks. Should I try to fix it and submit a PR? Do you think the correct entry point is to update @docusaurus/Link to take a new prop (e.g. mailto)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants