{"id":15698952,"url":"https://github.com/jonschlinkert/path-starts-with","last_synced_at":"2025-05-07T22:46:26.603Z","repository":{"id":57320727,"uuid":"88479751","full_name":"jonschlinkert/path-starts-with","owner":"jonschlinkert","description":"Returns true if a filepath starts with the given string. Works with windows and posix/unix paths.","archived":false,"fork":false,"pushed_at":"2023-07-29T23:27:06.000Z","size":19,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T10:02:04.095Z","etag":null,"topics":["endswith","file","filepath","fs","javascript","jonschlinkert","leading-slash","path","posix","slash","startswith","string","windows"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert/path-starts-with","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/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jonschlinkert","tidelift":"npm/path-starts-with"}},"created_at":"2017-04-17T06:42:37.000Z","updated_at":"2023-07-29T23:23:39.000Z","dependencies_parsed_at":"2024-06-18T18:42:12.451Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/path-starts-with","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"bf7301e57c84399926c75e3d683a7a1c4b7a1214"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpath-starts-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpath-starts-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpath-starts-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpath-starts-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/path-starts-with/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252463423,"owners_count":21751763,"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":["endswith","file","filepath","fs","javascript","jonschlinkert","leading-slash","path","posix","slash","startswith","string","windows"],"created_at":"2024-10-03T19:36:35.071Z","updated_at":"2025-05-07T22:46:26.585Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jonschlinkert","https://tidelift.com/funding/github/npm/path-starts-with"],"categories":[],"sub_categories":[],"readme":"# path-starts-with [![NPM version](https://img.shields.io/npm/v/path-starts-with.svg?style=flat)](https://www.npmjs.com/package/path-starts-with) [![NPM monthly downloads](https://img.shields.io/npm/dm/path-starts-with.svg?style=flat)](https://npmjs.org/package/path-starts-with) [![NPM total downloads](https://img.shields.io/npm/dt/path-starts-with.svg?style=flat)](https://npmjs.org/package/path-starts-with)\n\n\u003e Returns true if a filepath starts with the given string. Works with windows and posix/unix paths.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save path-starts-with\n```\n\n## Usage\n\n```js\nvar startsWith = require('path-starts-with');\n\nconsole.log(startsWith('foo/bar', 'foo')); //=\u003e true\nconsole.log(startsWith('foo/bar', 'bar')); //=\u003e false\n```\n\n## Negation\n\nPrefix the substring with `!` to return true when the path _does not_ start with the substring.\n\n```js\nconsole.log(startsWith('foo/bar', '!foo')); //=\u003e false\nconsole.log(startsWith('foo/bar', '!bar')); //=\u003e true\n```\n\n## options\n\n### options.nocase\n\n**Type**: `boolean`\n\n**Default**: `false`\n\nDisable case sensitivity.\n\n```js\nstartsWith('foo/bar', 'FOO');                 \n//=\u003e false\nstartsWith('foo/bar', 'FOO', {nocase: true}); \n//=\u003e true\n```\n\n### options.partialMatch\n\n**Type**: `boolean`\n\n**Default**: `false`\n\nAllow partial matches:\n\n```js\nstartsWith('foobar', 'foo');  //=\u003e false                 \nstartsWith('foo.bar', 'foo'); //=\u003e false                 \n\nstartsWith('foobar', 'foo', {partialMatch: true});  //=\u003e true \nstartsWith('foo.bar', 'foo', {partialMatch: true}); //=\u003e true \n```\n\n## Comparison behavior\n\n### Windows paths\n\nBackslashes are converted to forward slashes before the comparison is done. Thus, both of the following would be `true`:\n\n```js\nconsole.log(startsWith('foo\\\\bar', 'foo/bar')); //=\u003e true\nconsole.log(startsWith('foo/bar', 'foo\\\\bar')); //=\u003e true\n```\n\n### Leading dot-slash\n\nLeading `./` is stripped from both the filepath and substring. Thus, both of the following would be `true`:\n\n```js\nconsole.log(startsWith('./foo/bar', 'foo')); //=\u003e true\nconsole.log(startsWith('foo/bar', './foo')); //=\u003e true\n```\n\n### Leading slashes\n\nWhen the substring is prefixed with leading slashes, _the number of leading slashes_ must match exactly.\n\n```js\nconsole.log(startsWith('/foo', '/foo'));      //=\u003e true\nconsole.log(startsWith('/foo/bar', '/foo'));  //=\u003e true\n\nconsole.log(startsWith('/foo/bar', '//foo')); //=\u003e false\nconsole.log(startsWith('//foo/bar', '/foo')); //=\u003e false\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path \"Return true if a file path contains the given path.\")\n* [normalize-path](https://www.npmjs.com/package/normalize-path): Normalize slashes in a file path to be posix/unix-like forward slashes. Also condenses repeat slashes… [more](https://github.com/jonschlinkert/normalize-path) | [homepage](https://github.com/jonschlinkert/normalize-path \"Normalize slashes in a file path to be posix/unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes, unless disabled.\")\n* [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with \"Return `true` if a file path ends with the given string/suffix.\")\n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2023, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on July 29, 2023._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fpath-starts-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fpath-starts-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fpath-starts-with/lists"}