Skip to content

Allow ~/path as <img src="~/..."> with ~ alias #13460

Open
@OrbisK

Description

@OrbisK

Vue version

3.5.16

Link to minimal reproduction

https://github.com/OrbisK/vue-img-src-tilde

Steps to reproduce

  1. pnpm i
  2. pnpm dev
  3. Error. The first '~' is always stripped.

What is expected?

The first ~ should not be stripped.

What is actually happening?

export function parseUrl(url: string): UrlWithStringQuery {
const firstChar = url.charAt(0)
if (firstChar === '~') {
const secondChar = url.charAt(1)
url = url.slice(secondChar === '/' ? 2 : 1)
}
return parseUriParts(url)
}

This does always remove the first ~

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 36.29 GB / 62.58 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 23.5.0 - ~/.nvm/current/bin/node
    npm: 10.9.2 - ~/.nvm/current/bin/npm
    pnpm: 8.15.9 - ~/.nvm/current/bin/pnpm
    bun: 1.1.42 - ~/.nvm/current/bin/bun
  Browsers:
    Chrome: 130.0.6723.69
  npmPackages:
    vue: ^3.5.13 => 3.5.16

Any additional comments?

Nuxt uses ~ as alias for the /app directory.

Ref: vitejs/vite-plugin-vue#15
Ref: nuxt/nuxt#32119 (comment)

/cc @danielroe

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions