elements icon indicating copy to clipboard operation
elements copied to clipboard

Contact email link is invalid when using hash router

Open Thomasdezeeuw opened this issue 3 years ago • 6 comments

Describe the bug

When using router="hash" the contact email becomes a (not found) page link instead of a mailto: link.

To Reproduce

  1. Given this OpenAPI document:
openapi: "3.1.0"
info:
  title: My API
  contact:
    name: Our team
    email: [email protected]
  1. Using the HTML found in https://github.com/stoplightio/elements/blob/main/docs/getting-started/elements/html.md, using <elements-api router="hash" ...>.
  2. Open the HTML file and click "Contact Our team" under the "Additional Information" header.

Expected behavior

Expect a mailto: link to be opened, but it links to #/mailto:team@example instead.

Thomasdezeeuw avatar Feb 17 '22 14:02 Thomasdezeeuw

Related code is here https://github.com/stoplightio/elements/blob/264e31b280f2f745597715ec4582a49e1f3bfd60/packages/elements-core/src/components/Docs/HttpService/AdditionalInfo.tsx#L14-L32. But perhaps this should be fixed in the MarkdownViewer instead and/or where the links get converted to "hashed" urls (starting with #).

Thomasdezeeuw avatar Feb 17 '22 14:02 Thomasdezeeuw

The bug also breaks relative links in html and markdown, there is always # prefixed.

sbiastoch avatar Feb 21 '22 11:02 sbiastoch

This is in 7.5.8 but not in 7.5.7 so I guess it's one of these commits that introduced the issue:

281285b9 fix(elements-dev-portal): use react-router-dom link (#1989) 3faf02fa chore: refResolver param in Docs and NodeContent (#1984) a512d800 fix: responseType slow regex check (#1979)

My guess is the refResolver one (ping @domagojk).

andrelaszlo avatar Mar 08 '22 17:03 andrelaszlo

I am using Elements as a Web Component and corruption happens with history router too. The result is absolute link (with basePath="/api/docs") /api/docs/mailto:[email protected]

oldium avatar Jul 08 '22 08:07 oldium

Is an alternative possible at this time? I'm on version 7.7.9 and it's still not resolved.

spooky063 avatar Jan 31 '23 15:01 spooky063