Skip to content

[BUG] since v4 [email protected]:user/package-2#semver:^1.0.0 syntax is handled incorrectly #148

@JamesHenry

Description

@JamesHenry

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

As of 8.1.2 of npm-package-arg, a particular style of git URL specifying a semver range gets misinterpreted as a directory type instead of git.

I narrowed it down to this commit: npm/npm-package-arg@881f1c3 in which hosted-git-info was updated from v3 to v4.

Repro (using npm-package-arg):

index.js

const npa = require("npm-package-arg");

// Incorrect as of 8.1.2 of npm-package-arg, which is v4 of hosted-git-info instead of v3
console.log(npa.resolve('package-2', '[email protected]:user/package-2#semver:^1.0.0').type); // "directory"

// Correct

// (version range removed)
console.log(npa.resolve('package-2', '[email protected]:user/package-2#semver').type); // "git"

// (alternative syntax for start of URL, version range still present)
console.log(npa.resolve('package-2', 'github:user/package-2#semver:^1.0.0').type); // "git"
console.log(npa.resolve('package-2', 'git+ssh://github.com:user/package-2#semver:^1.0.0').type); // "git"
console.log(npa.resolve('package-2', 'git://github.com:user/package-2#semver:^1.0.0').type); // "git"

Expected Behavior

I expect to [email protected]:user/package-2#semver:^1.0.0 be handled correctly by hosted-git-info

(therefore allowing console.log(npa.resolve('package-2', '[email protected]:user/package-2#semver:^1.0.0').type); to correctly log "git")

Steps To Reproduce

Create the index.js file as I provided above and run node index.js

Environment

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority 2will get attention when we're freed up

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions