{"id":22423400,"url":"https://github.com/prantlf/common-path-start","last_synced_at":"2025-07-22T15:33:11.696Z","repository":{"id":32428495,"uuid":"133345937","full_name":"prantlf/common-path-start","owner":"prantlf","description":"Detects the same starting part of the path in an array of file paths and returns it, its length, or it cuts it from the specified file paths.","archived":false,"fork":false,"pushed_at":"2022-05-27T06:57:31.000Z","size":162,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-16T11:08:34.692Z","etag":null,"topics":["common","cut","path","start"],"latest_commit_sha":null,"homepage":null,"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/prantlf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-14T10:44:11.000Z","updated_at":"2022-05-27T06:50:59.000Z","dependencies_parsed_at":"2022-09-18T00:51:05.741Z","dependency_job_id":null,"html_url":"https://github.com/prantlf/common-path-start","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/prantlf/common-path-start","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fcommon-path-start","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fcommon-path-start/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fcommon-path-start/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fcommon-path-start/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/common-path-start/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fcommon-path-start/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266520731,"owners_count":23942324,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["common","cut","path","start"],"created_at":"2024-12-05T18:11:15.615Z","updated_at":"2025-07-22T15:33:11.545Z","avatar_url":"https://github.com/prantlf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# common-path-start\n\n[![Latest version](https://img.shields.io/npm/v/common-path-start)\n ![Dependency status](https://img.shields.io/librariesio/release/npm/common-path-start)\n](https://www.npmjs.com/package/common-path-start)\n[![Coverage](https://codecov.io/gh/prantlf/common-path-start/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/common-path-start)\n\nDetects the same starting part of the path in an array of file paths and returns it, its length, or it cuts it from the specified file paths.\n\n## Example\n\nIf you have the following file paths:\n\n```text\nsnapshots/fun/hmpg.net.html\nsnapshots/fun/xkcd.com.html\nsnapshots/wikimedia.org.html\n```\n\nThis plugin lets you detects \"snapshots/\" as the common path start, its length 10 characters, or cut the common start from every file path producing:\n\n```text\nfun/hmpg.net.html\nfun/xkcd.com.html\nwikimedia.org.html\n```\n\n## Installation\n\nYou need [node \u003e= 6][node]. Install the package using your favourite package manager:\n\n```sh\nnpm i common-path-start\npnpm i common-path-start\nyarn add common-path-start\n```\n\n## Programmatic Usage\n\nThis module exports several static functions operating on file paths, which use forward slash as a separator.\n\n```js\nconst {getCommonPathStart} = require('common-path-start')\nconst paths = [\n  'snapshots/fun/hmpg.net.html',\n  'snapshots/fun/xkcd.com.html',\n  'snapshots/wikimedia.org.html'\n]\nconst commonPathStart = getCommonPathStart(paths) // \"snapshots/\"\n```\n\n### getCommonPathStart (paths) : string\n\nExpects an array of strings with file paths and returns a string with the common path start, or an empty string, if there is no common starting directory among all file paths.\n\n### getCommonPathLength (paths) : number\n\nExpects an array of strings with file paths and returns the count of characters of the common path start, or zero, if there is no common starting directory among all file paths.\n\n### cutCommonPathStart (paths) : array\n\nExpects an array of strings with file paths and returns a new array with file paths with the common path start cut away, or the same file path array, if there is no common starting directory among all file paths.\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style.\n\n## License\n\nCopyright (c) 2018-2022 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[node]: http://nodejs.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fcommon-path-start","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Fcommon-path-start","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fcommon-path-start/lists"}