elements
elements copied to clipboard
Contact email link is invalid when using hash router
Describe the bug
When using router="hash"
the contact email becomes a (not found) page link instead of a mailto:
link.
To Reproduce
- Given this OpenAPI document:
openapi: "3.1.0"
info:
title: My API
contact:
name: Our team
email: [email protected]
- Using the HTML found in https://github.com/stoplightio/elements/blob/main/docs/getting-started/elements/html.md, using
<elements-api router="hash" ...>
. - 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.
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 #
).
The bug also breaks relative links in html and markdown, there is always #
prefixed.
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).
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]
Is an alternative possible at this time? I'm on version 7.7.9 and it's still not resolved.