Skip to content

Commit eca53e7

Browse files
authored
fix: remove .git suffix from Sourcehut https URLs (#326)
Sourcehut 404s on HTTPS URLs ending in `.git` (unlike GitHub/GitLab/Bitbucket), so `httpstemplate` was producing invalid clone URLs. Fixes npm/cli#9174
1 parent 4862744 commit eca53e7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/hosts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ hosts.sourcehut = {
198198
filetemplate: ({ domain, user, project, committish, path }) =>
199199
`https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || 'HEAD'}/${path}`,
200200
httpstemplate: ({ domain, user, project, committish }) =>
201-
`https://${domain}/${user}/${project}.git${maybeJoin('#', committish)}`,
201+
`https://${domain}/${user}/${project}${maybeJoin('#', committish)}`,
202202
tarballtemplate: ({ domain, user, project, committish }) =>
203203
`https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || 'HEAD'}.tar.gz`,
204204
bugstemplate: () => null,

test/sourcehut.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test('string methods populate correctly', () => {
105105
'https://git.sr.ht/~foo/bar/tree/HEAD/lib/index.js#l100'
106106
)
107107
assert.strictEqual(parsed.docs(), 'https://git.sr.ht/~foo/bar#readme')
108-
assert.strictEqual(parsed.https(), 'https://git.sr.ht/~foo/bar.git')
108+
assert.strictEqual(parsed.https(), 'https://git.sr.ht/~foo/bar')
109109
assert.strictEqual(parsed.shortcut(), 'sourcehut:~foo/bar')
110110
assert.strictEqual(parsed.path(), '~foo/bar')
111111
assert.strictEqual(parsed.tarball(), 'https://git.sr.ht/~foo/bar/archive/HEAD.tar.gz')
@@ -123,7 +123,7 @@ test('string methods populate correctly', () => {
123123

124124
const extra = HostedGit.fromUrl('https://@git.sr.ht/~foo/bar#fix/bug')
125125
assert.strictEqual(extra.hash(), '#fix/bug')
126-
assert.strictEqual(extra.https(), 'https://git.sr.ht/~foo/bar.git#fix/bug')
126+
assert.strictEqual(extra.https(), 'https://git.sr.ht/~foo/bar#fix/bug')
127127
assert.strictEqual(extra.shortcut(), 'sourcehut:~foo/bar#fix/bug')
128128
assert.strictEqual(extra.ssh(), '[email protected]:~foo/bar.git#fix/bug')
129129
assert.strictEqual(extra.sshurl(), 'git+ssh://[email protected]/~foo/bar.git#fix/bug')

0 commit comments

Comments
 (0)