Skip to content

ExternalDocs URL ignored due to incorrect protocol handling in getSanitizedUrl #303

Description

@gdec31

Hello,

I’ve noticed an issue with the handling of the externalDocs URL in the OpenAPI specification.
The generated link is always rendered as:

<a href>Navigate to documentation ↗</a>

Even when a valid URL is provided in the OpenAPI spec, for example:


externalDocs:
  description: "More details here"
  url: http://localhost:8080/doc/more/details

It seems the issue originates from the method:

src/utils/common-utils.js#getSanitizedUrl

The problem is that the URL object returns the protocol with a trailing colon (http: or https:), not http or https.
As a result, the validation fails and the `` attribute ends up empty.

I proposed the fix below :
return url.protocol === 'http:' || url.protocol === 'https:' ? url : '';

The reference:
URL Standard – protocol

"The protocol getter steps are to return this’s URL’s scheme, followed by U+003A (:)."

Thanks for your work, I really appreciate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions