Skip to content
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

relative_urls plugin has trouble with trailing slashes in URLs #711

Closed
satgo1546 opened this issue Dec 30, 2024 · 1 comment
Closed

relative_urls plugin has trouble with trailing slashes in URLs #711

satgo1546 opened this issue Dec 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@satgo1546
Copy link

Version

2.4.3

Platform

Linux (WSL), should also reproduce on other platforms

What steps will reproduce the bug?

In a directory with two files:

  • _config.ts:

    import lume from "lume/mod.ts";
    import relativeUrls from "lume/plugins/relative_urls.ts";
    
    const site = lume();
    site.use(relativeUrls());
    export default site;
  • test.md:

    ---
    url: /a.html
    ---
    
    [Go to index](/)

Run lume.

How often does it reproduce? Is there a required condition?

Always reproducible.

What is the expected behavior?

The URL / should be translated to ., so that the link leads to index.html.

What do you see instead?

In _site/a.html, the URL / is translated to an empty string. The link leads to a.html itself.

<!DOCTYPE html>
<html><head></head><body><p><a href="">Go to index</a></p>
</body></html>

Additional information

There are many other cases where the plugin fails; the above is just an example.

It is problematic even if url is not set explicitly: Trailing slashes in URLs are removed, but prettyUrls (on by default) requires them. While Lume dev server handles missing trailing slashes by redirection, not all static hosting providers do.

The plugin uses jsr:@std/path/posix, a module intended for POSIX filesystems. In POSIX path operations, trailing slashes are ignored. But in URLs, they are significant.

@satgo1546 satgo1546 added the bug Something isn't working label Dec 30, 2024
@oscarotero
Copy link
Member

Thank you for reporting this!
I just commited a fix that will be available in the next Lume version.
If you don't want to wait to the next version, run deno task lume upgrade --dev to use the latest development version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants