Skip to content

Incorrect URL resolution for relative links on first click #37

@develmusa

Description

@develmusa

When using relative links in embedded Draw.io diagrams, the target URL is sometimes constructed incorrectly on the first click. This leads to a broken link ("404 Not Found"). However, if the user navigates back and clicks the same link a second time, the URL is resolved correctly and the link works as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Draw.io diagram.
  2. Add a shape or text element.
  3. Assign a relative link to this element (e.g., ../My-Other-Page).
  4. Embed the diagram into an MkDocs page using the mkdocs-drawio-plugin.
  5. Build and serve the MkDocs site.
  6. Navigate to the page containing the diagram.
  7. Click the relative link for the first time.

Actual Behavior
The browser attempts to navigate to an incorrectly formed URL, which appears to be resolved against a base path rather than the full path of the current page.

Expected Behavior
The relative link should resolve correctly on the first click, navigating to the proper target page.

Example

Let's assume the current page URL is https://docs.example.com/project/section/sub-section/current-page/.

  • Link in diagram: ../Target%20Page
  • URL on first click (Incorrect): https://docs.example.com/project/Target%20Page
  • URL on second click (Correct): https://docs.example.com/project/section/sub-section/Target%20Page/

Additional Context
This behavior suggests that the script handling the link redirection might not be correctly identifying the full base URL on the initial page load or first interaction, but successfully identifies it on subsequent attempts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions