docsifyjs / docsify

🃏 A magical documentation site generator.
https://docsify.js.org
MIT License
27.47k stars 5.67k forks source link

image url begin with "/" should be AbsolutePath,not RelativePath #2369

Closed poerlang closed 7 months ago

poerlang commented 7 months ago

Bug Report

Steps to reproduce

add a md file in a sub1 dir /docs/sub1/test.md

add a img.png in /docs/images

add a imgLink in sub1/test.md: ![](/images/img.png)

Current behaviour

docsify render the image url to :

/./sub1/images/img.png

Expected behaviour

docsify should render the image url to :

/images/img.png

Please create a reproducible sandbox

reproducible sandbox

poerlang commented 7 months ago

the regular expression in isAbsolutePath function only considers the cases ofhttp://or https://, but does not take into account URLs that start with /, so the bug happen

var isAbsolutePath = cached(function (path) {
    return /(:|(\/{2}))/g.test(path);
  });
Koooooo-7 commented 7 months ago

Hi @poerlang , thx for your report! We already raised this issue in #1891, we still discuss on how to refactor its behavior and keep the things work more as expectation.

jhildenbiddle commented 7 months ago

Bug acknowledged. Tracking with #1891.