Skip to content

Commit 2528e96

Browse files
committed
fix: git link parse error
The git link of SSH type cannot be parsed correctly.
1 parent 8ce8f0f commit 2528e96

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/checkAndFormatView.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const { version } = require('../package.json')
22

33

4+
5+
const gitUrlRegexp = /((git|ssh|http(s)?)|(git@[\w.]+))(:(\/\/)?)([\w.@:/\-~]+)(\.git)(\/)?$/
6+
47
module.exports = v => {
58
const view = { ...v }
69

@@ -9,9 +12,12 @@ module.exports = v => {
912
if (/github.com/.test(url)) {
1013
view.repository = { ...view.repository, type: 'github' }
1114

12-
const matched = url.match(/([-a-zA-Z0-9@:%_\+.~#?&=]+)\/([-a-zA-Z0-9@:%_\+.~#?&=]+)(?=\.git$)/)
15+
const matched = url.match(gitUrlRegexp)
1316
if (matched) {
14-
const [, user, name] = matched
17+
const [, , , , , , , links] = matched
18+
console.log(links)
19+
const [user, name] = links.split('/').slice(-2)
20+
console.log(user, name)
1521
view.repository = { ...view.repository, type: 'github', user, name }
1622
}
1723
}

0 commit comments

Comments
 (0)