Skip to content

Commit

Permalink
Update get_file_extension.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx authored Oct 18, 2023
1 parent 7d5b715 commit 2d5e8e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/files/get_file_extension.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* This function takes in a path to a file and returns the file extension.
* This function takes in a path to a file and returns the file extension (without the `.`).
* @param path The path to the file
* @returns The file extension
*/
export function getFileExtension(path : string) : string {
return path.replace(/^.*?((?:\.\w+)+)$/, (_, extension) => extension);
return path.replace(/.+\.([^/.]+$)/, (_, extension) => extension);
}

0 comments on commit 2d5e8e1

Please sign in to comment.