Skip to content

When relativePath: true, even absolute paths are for icons in sidebar are resolved as relative. #877

Description

@filipgoc

Bug Report

When relativePath: true, absolute paths are for icons in sidebar are resolved as relative.

Steps to reproduce

Set relativePath: true

└── docs
    ├── _sidebar.md
    ├── guide.md
    └── subfolder
        ├── _sidebar.md
        ├── guide.md

In the both _sidebar files, I have - [![](/assets/home.svg)Home](/ "Home")

What is current behaviour

While the link gets resolved as absolute (👍 ),
for images,
the data-origin is correct (👍 ), but the img scr is relative and thus failing (👎 )

<a href="#/" title="Home"><img src="/subfolder/assets/home.svg" data-origin="/assets/home.svg" alt="">Home</a>

What is the expected behaviour

The img src should be absolute:
"/assets/home.svg"

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS:

  • Node.js version:

  • npm/yarn version:

  • Browser version:

  • Docsify version: 4.9.4

  • Docsify plugins: pagination, themeable

Activity

  1. tiptronic commented on Jul 24, 2019

    @tiptronic

    While I understand your intention (and you're right), here's a small note:
    But both of the mentioned paths are absolute paths:

    • /subfolder/assets/home.svg
    • /assets/home.svg

    they simple start at a different root-directory. A relative path would ideally start with an './' (or even without a slash).

    This is an important feature, because otherwise it's cumbersome to link from one .md to the contents of another <sibling/parent/child>.md.

  2. timaschew commented on Nov 22, 2019

    @timaschew
    Member

    Resolving image seems to use a different algorithm that's why images are not working.

  3. stale commented on Feb 4, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  4. jcayzac commented on Dec 10, 2020

    @jcayzac

    I can reproduce this in any page:

    ![Secure website image](/_assets/secure-website.png)

    is resolved as:

    • {base-path}#/_assets/secure-website.png when i'm e.g. at #/quickstart, but as
    • {base-path}#/ja/_assets/secure-website.png, which doesn't exists and returns 404, when i'm e.g. at #/ja/quickstart.

    Given the URL is absolute I don't understand why Docsify feels like it should consider it relative, especially since I don't set relativePath.

  5. jhildenbiddle commented on Mar 2, 2024

    @jhildenbiddle
    Member

    Bug acknowledged. Tracking with #1891.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions