{"id":13526245,"url":"https://github.com/sindresorhus/file-url","last_synced_at":"2025-04-05T15:08:57.386Z","repository":{"id":15704235,"uuid":"18442145","full_name":"sindresorhus/file-url","owner":"sindresorhus","description":"Convert a file path to a file URL: `unicorn.jpg` → `file:///Users/sindresorhus/unicorn.jpg`","archived":false,"fork":false,"pushed_at":"2024-04-01T17:02:35.000Z","size":21,"stargazers_count":61,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T05:24:28.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-04-04T14:46:53.000Z","updated_at":"2025-01-07T20:10:55.000Z","dependencies_parsed_at":"2024-04-17T03:50:06.746Z","dependency_job_id":"e8082231-e0af-479f-bcfb-47ed0443b811","html_url":"https://github.com/sindresorhus/file-url","commit_stats":{"total_commits":29,"total_committers":7,"mean_commits":4.142857142857143,"dds":0.2068965517241379,"last_synced_commit":"3e340bd3563ca6c5a631ebbb3fabc07b3ff588d1"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffile-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffile-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffile-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffile-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/file-url/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246820075,"owners_count":20839159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:01:26.891Z","updated_at":"2025-04-05T15:08:57.361Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Repository","JavaScript"],"sub_categories":["URL"],"readme":"# file-url\n\n\u003e Convert a file path to a file url: `unicorn.jpg` → `file:///Users/sindresorhus/unicorn.jpg`\n\n\u003e [!TIP]\n\u003e Node.js supports this built-in now with [`url.pathToFileURL(path)`](https://nodejs.org/api/url.html#urlpathtofileurlpath).\n\n## Install\n\n```sh\nnpm install file-url\n```\n\n## Usage\n\n```js\nimport fileUrl from 'file-url';\n\nfileUrl('unicorn.jpg');\n//=\u003e 'file:///Users/sindresorhus/dev/file-url/unicorn.jpg'\n\nfileUrl('/Users/pony/pics/unicorn.jpg');\n//=\u003e 'file:///Users/pony/pics/unicorn.jpg'\n\nfileUrl('unicorn.jpg', {resolve: false});\n//=\u003e 'file:///unicorn.jpg'\n```\n\n## API\n\n### fileUrl(filePath, options?)\n\nReturns the `filePath` converted to a file URL.\n\nIt does not support filenames with backslashes.\n\n#### filePath\n\nType: `string`\n\nThe file path to convert.\n\n#### options\n\nType: `object`\n\n##### resolve\n\nType: `boolean`\\\nDefault: `true`\n\nPassing `false` will make it not call `path.resolve()` on the path.\n\n## Related\n\n- [file-url-cli](https://github.com/sindresorhus/file-url-cli) - CLI for this module\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffile-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Ffile-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffile-url/lists"}