https://github.com/vweevers/is-git-ref-name-valid
Check that a git reference name is well formed.
https://github.com/vweevers/is-git-ref-name-valid
git nodejs npm-package refname
Last synced: 5 months ago
JSON representation
Check that a git reference name is well formed.
- Host: GitHub
- URL: https://github.com/vweevers/is-git-ref-name-valid
- Owner: vweevers
- License: mit
- Created: 2020-11-28T17:57:26.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-01T09:43:02.000Z (over 2 years ago)
- Last Synced: 2025-10-27T04:39:04.450Z (8 months ago)
- Topics: git, nodejs, npm-package, refname
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-git-ref-name-valid
**Check that a git reference name is well formed, per [`git-check-ref-format(1)`](https://git-scm.com/docs/git-check-ref-format).**
[](https://www.npmjs.org/package/is-git-ref-name-valid)
[](https://www.npmjs.org/package/is-git-ref-name-valid)
[](https://standardjs.com)
## Usage
```js
const validRef = require('is-git-ref-name-valid')
validRef('refs/heads/foo.bar') // true
validRef('refs/heads/foo^bar') // false
```
Same as `git check-ref-format`, the reference name must contain a `/` by default. This can be disabled:
```js
validRef('ünicöde') // false
validRef('ünicöde', true) // true
```
To validate branch names, for which there are additional rules, use [`is-git-branch-name-valid`](https://github.com/vweevers/is-git-branch-name-valid).
## API
### `validRef(name[, onelevel])`
Takes a string `name` and an optional `onelevel` boolean. Returns true if `name` is well formed. Throws if `name` is not a string. If `onelevel` is true then `name` does not have to contain a `/`.
## Install
With [npm](https://npmjs.org) do:
```
npm install is-git-ref-name-valid
```
## License
[MIT](LICENSE) © Vincent Weevers