unjs/ufo

windows paths aren't handled when parsing

danielroe opened this issue · 3 comments

parseURL('D:/a/framework/framework/test/fixtures/basic/pages/[...slug].vue?macro=true')
// {
//   protocol: '',
//   auth: '',
//   host: '',
//   pathname: '',
//   search: '',
//   hash: ''
// }
pi0 commented

Behavior of new URL('D:/a/framework/framework/test/fixtures/basic/pages/[...slug].vue?macro=true'):

hash: ""
host: ""
hostname: ""
href: "d:/a/framework/framework/test/fixtures/basic/pages/[...slug].vue?macro=true"
origin: "null"
password: ""
pathname: "/a/framework/framework/test/fixtures/basic/pages/[...slug].vue"
port: ""
protocol: "d:"
search: "?macro=true"
searchParams: URLSearchParams {}
username: ""

While this is not a valid input, we might improve ufo behavior to be closer to URL.

Hello,

Actually, it's a regression introduced with this PR #46

Before that "fix":

{
  pathname: 'D:/a/framework/framework/test/fixtures/basic/pages/[...slug].vue',
  search: '?macro=true',
  hash: ''
}

Actually, it's a path protocol? No?

Any suggestion on how to resolve this @pi0?

Thanks!

pi0 commented

Supporting windows URLs without file:// protocol can be really tricky. I don't think we can make it better than this. You might use pathToFileURL from mlly to normalize them before parsing.