Skip to content

Commit

Permalink
fix(extname): avoid regex look-behinds for safari support (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 18, 2022
1 parent aa7772d commit c0cec97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/path.ts
Expand Up @@ -182,10 +182,10 @@ export const toNamespacedPath: typeof path.toNamespacedPath = function (p) {
}

// extname
const _EXTNAME_RE = /(?<!^)\.[^/.]+$/
const _EXTNAME_RE = /.(\.[^/.]+)$/
export const extname: typeof path.extname = function (p) {
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p))
return (match && match[0]) || ''
return (match && match[1]) || ''
}

// relative
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Expand Up @@ -17,10 +17,10 @@ export function normalizeAliases (_aliases: Record<string, string>) {
return aliases
}

const FILENAME_RE = /(?<=^|[\\/])([^\\/]+?)(?=(\.[^.]+)?$)/
const FILENAME_RE = /(^|[\\/])([^\\/]+?)(?=(\.[^.]+)?$)/

export function filename (path: string) {
return path.match(FILENAME_RE)?.[0]
return path.match(FILENAME_RE)?.[2]
}

// --- internals ---
Expand Down

0 comments on commit c0cec97

Please sign in to comment.