Skip to content

path: make some @std/path functions work with file URL object #5537

Closed

Description

@kt3k

As FS APIs in Deno works with file URL object, it would make sense to support file URL input with path.dirname.

dirname(new URL("file:///path/to/dir/file")) // returns `/path/to/dir` on unix
dirname(new URL("file:///C:/path/to/dir/file")) // returns `C:\path\to\dir` on windows

This probably would throw with non-file URLs.

I think this mostly addresses the motivation we added std/url.

  • dirname()
  • extname()
  • join()
  • basename
  • normalize

Activity

  1. added
    enhancement
    on Jul 26, 2024
  2. iuioiua commented on Aug 2, 2024

    @iuioiua
    Contributor

    Just dirname() or the other functions too?

  3. kt3k commented on Aug 2, 2024

    @kt3k
    ContributorAuthor

    I think this also makes sense for other functions such as basename, extname, common, join, relative, and resolve

  4. changed the title [-]path: make `dirname` work with file URL object[/-] [+]path: make some `@std/path/posix` functions work with file URL object[/+] on Aug 2, 2024
  5. changed the title [-]path: make some `@std/path/posix` functions work with file URL object[/-] [+]path: make some `@std/path` functions work with file URL object[/+] on Aug 6, 2024
  6. kt3k commented on Aug 6, 2024

    @kt3k
    ContributorAuthor

    I don't think we need to limit this to std/path/posix as file URL object is platform independent

  7. iuioiua commented on Aug 20, 2024

    @iuioiua
    Contributor

    I think @std/path in its current state is good enough. Though, it's not a strong opinion of mine. @kt3k, do you still strongly believe we should have these additions? If yes, are you able to add them so we can progress with #5630?

  8. kt3k commented on Aug 29, 2024

    @kt3k
    ContributorAuthor

    I'd suggest we would target basename and normalize instead of resolve and relative for the remaining items as they are something exposed as std/url APIs.

    We can revisit resolve and relative as they are requested

  9. iuioiua commented on Aug 29, 2024

    @iuioiua
    Contributor

    SGTM

  10. kt3k commented on Sep 4, 2024

    @kt3k
    ContributorAuthor

    done

  11. added a commit that references this issue on Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementpath

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions