-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
baseUrl with relative prefix not working as expected. #1466
Comments
could you remove the slash from the url? ![alt text](favicon.ico "relative") |
Yeah, I think it would work as long as you never use the slash at the start of relative route. Do you know if there is a standard expectation on how to define the relative routes? Is the slash frowned upon? I noticed in my demo it would display the favicon with or without the slash. |
I believe most servers treat consecutive slashes as a single slash so it shouldn't affect anything. |
Good enough for me. Thanks for the response! |
@UziTech not if the slashes are at the beginning of the line. E.g.: |
@VitaliyR Where does |
@UziTech it would not change if you will just request the website with this URL (like in address bar). But it will change if you will have a resource pointing to such url (e.g. img tag with src containing this url) |
@VitaliyR It seems to work for me. If I enter |
@UziTech please, try to use it in the actual HTML, not in the address bar. Like having a page with img tag with this url |
are you talking about that doesn't seems to be the issue. marked only adds the extra slash after the base url so it will never starts with two slashes unless two slashes are specified without a base url like |
const markdown = '![An Image](/images/pic01.jpg)';
const html = marked(markdown, { baseUrl: '/' }); // would be url with two slashes here Doesn't it looks like bug? Isn't it supposed to do something like path.join instead concat? |
I see. I guess in that case we should treat |
@UziTech Yeah, great! And also baseUrls could be like '/something/' (please, notice the last slash). I think it would make the issue as well (due to concatenating |
Ya in that case I guess we could remove the extra slash. @VitaliyR If you want to create a PR that fixes it I would be happy to review it. |
Describe the bug
For usage in github pages I'd like to use the baseUrl option to add a prefix of the project name for relative links. For instance with a github pages site like
matt.github.io/derp
withderp
being the project name. I'd like relative links to change from/link
to/derp/link
.Marked options
Markdown
Output html
What is actually happening is:
Maybe it is as simple as not inverting rtrim here:
https://github.com/markedjs/marked/blob/master/lib/marked.js#L1417
To Reproduce
This code sandbox should show the issue. Check the console
https://codesandbox.io/s/9ql03o5114
I was able to reproduce this in both 0.5.0 and 0.6.2.
Expected behavior
I expect html output to look like this:
The text was updated successfully, but these errors were encountered: