Registry / devops / git-up

git-up

JSON →
library2.4.0jsnpmunverified

git-up is a dedicated, low-level JavaScript utility designed for robust parsing of various Git URL formats, including SSH (e.g., `git@github.com:user/repo.git`) and HTTPS (`https://github.com/user/repo.git`). It meticulously breaks down a given URL into a structured object, exposing components like protocols, port, resource, user, pathname, hash, search, href, and the derived Git protocol. The current stable version is 8.1.1, with recent releases indicating active maintenance and the addition of TypeScript types in version 8.1.0. Its release cadence is somewhat irregular, often driven by updates to its core dependency, `parse-url`. A key differentiator is its specific focus on Git URL nuances, making it more reliable for Git-centric tooling compared to general-purpose URL parsers, which might not correctly interpret SSH syntax or project paths.

npm install git-up
INSTALL
IMPORT
SIG · GIT-UP
G
git-up
devopsjavascriptv2.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gitUp
import gitUp from 'git-up';
import { gitUp } from 'git-up';
For ESM, `gitUp` is the default export. For CommonJS, it is the module's direct export, typically accessed as `const gitUp = require('git-up');`.
GitUpResult
import type { GitUpResult } from 'git-up';
TypeScript users can import the `GitUpResult` interface for type safety when working with the parsed URL object, available since v8.1.0.
* as GitUp
import * as GitUp from 'git-up';
const GitUp = require('git-up');
Wildcard import can be used to access the module object, though direct import of `gitUp` is more common.

Demonstrates parsing both SSH and HTTPS Git URLs and logging the structured output, showcasing the detailed breakdown of URL components.

import gitUp from 'git-up'; console.log(gitUp('git@github.com:IonicaBizau/node-parse-url.git')); // Example Output: // { // protocols: [] // , port: null // , resource: 'github.com' // , user: 'git' // , pathname: '/IonicaBizau/node-parse-url.git' // , hash: '' // , search: '' // , href: 'git@github.com:IonicaBizau/node-parse-url.git' // , protocol: 'ssh' // } console.log(gitUp('https://github.com/IonicaBizau/node-parse-url.git')); // Example Output: // { // protocols: [ 'https' ] // , port: null // , resource: 'github.com' // , user: '' // , pathname: '/IonicaBizau/node-parse-url.git' // , hash: '' // , search: '' // , href: 'https://github.com/IonicaBizau/node-parse-url.git' // , protocol: 'https' // }
Debug
Known issues
breakingMajor dependency `parse-url` was upgraded to 9.x.x, which includes breaking changes. Review `parse-url` release notes for potential changes in URL parsing behavior and the structure of the output object.
fix
Thoroughly test existing parsing logic and adapt code if `parse-url` 9.x.x introduces changes to the parsed object structure or edge case handling.
affects: >=8.0.0
breakingUpgraded `parse-url` to 8.1.0, which was explicitly noted as a breaking change. Consult `parse-url`'s release notes for details on how URL parsing and output might have changed.
fix
Review `parse-url` 8.x.x documentation and update any code that relies on specific parsed URL properties or behaviors that may have been altered.
affects: >=7.0.0 <8.0.0
breakingIntroduced several breaking changes: trailing slashes in input URLs are now preserved in `pathname`, the `port` field is always a string (empty by default), a new `password` field is added (default `""`), and the `resource` field may now include the port (e.g., 'domain.com:4200').
fix
Update logic handling `pathname` to account for trailing slashes, ensure `port` is treated as a string, and adjust any code that expects specific `resource` formats or relies on the absence of a `password` field.
affects: >=6.0.0 <7.0.0
gotchaDue to compatibility issues with `normalize-url` (a transitive dependency of `parse-url@6.0.0`), `git-up` versions released around this period may exhibit broken or unexpected behavior in Safari browsers without a specific patch to `normalize-url`.
fix
For Safari compatibility, ensure `normalize-url` is updated or consider upgrading to `git-up@6.0.0` or later, as subsequent `parse-url` updates may have resolved the underlying issue. Always test thoroughly in Safari.
affects: >=4.0.5 <6.0.0
Errors
Common errors & fixes
TypeError: (0 , git_up__WEBPACK_IMPORTED_MODULE_0__.default) is not a function
Incorrect ESM import syntax; attempting to destructure a default export or using a named import when the module provides a default export.
fix
Change the import statement to `import gitUp from 'git-up';` to correctly import the default export.
Property 'protocol' does not exist on type 'GitUpResult'.
Accessing a property on the parsed object that may have been renamed, removed, or changed its type in a new major version, or using an outdated TypeScript type definition.
fix
Update `git-up` to the latest version and ensure your `node_modules/@types/git-up` are regenerated. Review the `GitUpResult` interface in the latest version for current property names and types, especially after major version bumps (e.g., `port` changed to `string` in v6).
Error: The "input" argument must be of type string. Received type object
Calling `gitUp()` with an argument that is not a string, or passing an unsupported input type.
fix
Ensure the `input` argument passed to `gitUp()` is always a string representing the Git URL to be parsed.
Upgrade
Version history
2.4.0latest on npm
Audit
Dependencies
parse-urlrequiredCore dependency for URL parsing logic, frequently updated with major versions impacting git-up.
Agent activity
6 hits · last 30 days
node
6
Resources
git-up — npm install git-up · libregistry