Skip to content

Conversation

@strager
Copy link

@strager strager commented Jun 12, 2020

BUG In Node.js on Windows, file: URLs have three slashes before the
drive letter. For example:

file:///c:/Users/strager/[snip]/nsfwjs/model.json

When converting a file: URL to a file path, NodeFileSystem's router
incorrectly preserves one leading slash. This results in a
drive-relative path, which refers to a different file than intended.
This leads to errors down the road:

Error: Path C:\C:\Users\strager\[snip]\nsfwjs\model.json does not exist: loading failed
    at C:\Users\strager\[snip]\node_modules\@tensorflow\tfjs-node\dist\io\file_system.js:67:23

Use Node.js' built-in functions for dealing with file: URLs instead of
hackily parsing them ourselves.

On POSIX systems, this commit should not change behavior.


This change is Reviewable

BUG In Node.js on Windows, file: URLs have three slashes before the
drive letter. For example:

    file:///c:/Users/strager/[snip]/nsfwjs/model.json

When converting a file: URL to a file path, NodeFileSystem's router
incorrectly preserves one leading slash. This results in a
drive-relative path, which refers to a different file than intended.
This leads to errors down the road:

    Error: Path C:\C:\Users\strager\[snip]\nsfwjs\model.json does not exist: loading failed
        at C:\Users\strager\[snip]\node_modules\@tensorflow\tfjs-node\dist\io\file_system.js:67:23

Use Node.js' built-in functions for dealing with file: URLs instead of
hackily parsing them ourselves.

On POSIX systems, this commit should not change behavior.
@strager
Copy link
Author

strager commented Dec 11, 2022

Ping! I still use this patch and I think it should be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants