-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Copy link
Description
deno 2.3.3 (stable, release, x86_64-unknown-linux-gnu)
Currently the suffix used in temporary generated files is $
, but because of this it makes it impossible to use import.meta.url
/import.meta.filename
properly in the examples if you want to reference the file itself.
It'd be better to use #
(url anchor) so when manipulating the url with either new URL()
or fromFileUrl()
you can get back the original filename easily without hacks like .replace("$", "#")
Also conceptually using the anchor spec would make sense too
#
is supported in windows path, and unix basically supports anything, so it shouldn't be a breaking change too
For example :
import { fromFileUrl } from "@std/path"
const path = fromFileUrl(import.meta.url)
console.log(path)
// file:///workspaces/mod.ts$97-101.ts
// → /workspaces/mod.ts$97-101.ts
await Deno.readTextFile(path) // throws not found error
Suggested :
import { fromFileUrl } from "@std/path"
const path = fromFileUrl(import.meta.url)
console.log(path)
// file:///workspaces/mod.ts#97-101.ts
// → /workspaces/mod.ts
await Deno.readTextFile(path) // OK!
magurotuna, JOTSR, dsherret and lishaduck
Metadata
Metadata
Assignees
Labels
No labels