Skip to content

Commit a9a372a

Browse files
committed
🐛 Fix _replacePath
1 parent 677723a commit a9a372a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules
33
.gitignore
44
*.go
55
*.json
6-
tmp
6+
tmp
7+
.node-version

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
.semver.yml
44
tmp
55
.release
6-
gitmoji-semver
6+
gitmoji-semver
7+
.node-version

src/buildPath.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ function _buildPath(url, configFile) {
4242
}
4343

4444
function _replacePath(pathname, format) {
45-
const replacedArr = []
45+
let replacedArr = []
4646
const pathArr = pathname.split('/')
4747
const formatArr = format.split('/')
4848
if (pathArr.length !== formatArr.length) {
49-
return false
49+
return
5050
}
5151
for (let j = 0; j < formatArr.length; j++) {
5252
if (pathArr[j] === formatArr[j]) {
@@ -55,10 +55,13 @@ function _replacePath(pathname, format) {
5555
}
5656
const val = formatArr[j].match(/^{.*}$/)
5757
if (val === null) {
58+
replacedArr = []
5859
break
5960
}
6061
replacedArr.push(formatArr[j].replace("{", "").replace("}", ""))
6162
}
63+
if (replacedArr.length === 0) return
64+
6265
const replacedPath = replacedArr.join("/")
6366
console.log(`format: ${format}`)
6467
return {

0 commit comments

Comments
 (0)