Skip to content

Commit

Permalink
fix(path-meta): prevent undefined error
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Sep 29, 2023
1 parent ea894c0 commit 1257cb5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/runtime/transformers/path-meta.ts
Expand Up @@ -6,12 +6,16 @@ import { defineTransformer } from './utils'

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

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

const [, filename, _extension] = parts[parts.length - 1].match(/(.*)\.([^.]+)$/)!
parts[parts.length - 1] = filename
const _path = parts.join('/')
const [, filename, _extension] = parts[parts.length - 1]?.match(/(.*)\.([^.]+)$/) || []

if (filename) {
parts[parts.length - 1] = filename
}

const _path = (parts || []).join('/')

return {
_source,
Expand Down

0 comments on commit 1257cb5

Please sign in to comment.