Skip to content

Commit 1257cb5

Browse files
committed
fix(path-meta): prevent undefined error
1 parent ea894c0 commit 1257cb5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/runtime/transformers/path-meta.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ import { defineTransformer } from './utils'
66

77
const SEMVER_REGEX = /^(\d+)(\.\d+)*(\.x)?$/
88

9-
const describeId = (_id: string) => {
10-
const [_source, ...parts] = _id.split(':')
9+
export const describeId = (id: string) => {
10+
const [_source, ...parts] = id.split(':')
1111

12-
const [, filename, _extension] = parts[parts.length - 1].match(/(.*)\.([^.]+)$/)!
13-
parts[parts.length - 1] = filename
14-
const _path = parts.join('/')
12+
const [, filename, _extension] = parts[parts.length - 1]?.match(/(.*)\.([^.]+)$/) || []
13+
14+
if (filename) {
15+
parts[parts.length - 1] = filename
16+
}
17+
18+
const _path = (parts || []).join('/')
1519

1620
return {
1721
_source,

0 commit comments

Comments
 (0)