Skip to content

Commit

Permalink
feat: 根据提供的文件名称/文件路径,获取文件后缀
Browse files Browse the repository at this point in the history
  • Loading branch information
fanzhiwen committed Sep 13, 2023
1 parent cd2310e commit 57db6d6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/fs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ export function getFileNameByPath(path: string): string {
return result
}

/**
* 根据提供的文件名称/文件路径,获取文件后缀
* @param path 文件路径/名称
* @return 文件后缀
*/
export function getExtByPath(path: string): string {
return path.substring(path.lastIndexOf('.') + 1)
}

/**
* 根据提供的文件路径,获取文件的目录路径。
* @param path 文件路径
Expand Down

0 comments on commit 57db6d6

Please sign in to comment.