Skip to content

relative_urls plugin has trouble with trailing slashes in URLs #711

@satgo1546

Description

@satgo1546

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions