Skip to content

resolve() lacks a trailing slash when using trailingSlash = always #14047

@charbelnicolas

Description

@charbelnicolas

Describe the bug

The following code no longer works when using resolve() for href and export const trailingSlash = 'always';. I was using base before but it is now being deprecated.

<Link href={resolve('/dashboard/settings/')} label="SETTINGS" />

resolve() always gets rid of the trailing slash

link.svelte component:

<script>

	import { page } from '$app/stores';

	let { href, label } = $props();

</script>

<a href={href} class="header-button font-medium" class:selected-link={$page.url.pathname === href} aria-label={label}>

	{label}

</a>

$page.url.pathname === href is never the same, one has a trailing slash, the other doesn't.

href = /portal/dashboard/settings and $page.url.pathname = /portal/dashboard/settings/

If using trailingSlash = always, resolve() should add it too IMO.

I tried using page from $app/state and I get the same result. I'm using let hrefWithSlash = $derived(${href}/); as a simple workaround

Reproduction

Sorry (really), reproducing this issue will likely be somewhat difficult for me. I hope the explanation above will do.

Logs

System Info

System:
    OS: Linux 6.15 Arch Linux
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
    Memory: 27.42 GB / 31.02 GB
    Container: Yes
    Shell: 5.3.3 - /bin/bash
  Binaries:
    Node: 24.4.1 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 11.5.1 - /usr/bin/npm
    pnpm: 8.14.0 - /usr/bin/pnpm
  Browsers:
    Chromium: 138.0.7204.168

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions