Skip to content

Commit

Permalink
fix(upload): 解决上传的文件后缀解析错误
Browse files Browse the repository at this point in the history
问题描述:
当文件名中包含多个“点”时,后缀取的不对

解决:
应当从后往前找
  • Loading branch information
Vinsea authored Jan 11, 2025
1 parent 46afe0d commit 96cc33a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/upload/src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ export default defineComponent({
}

const parseFileType = (name: string) => {
const index = name ? name.indexOf('.') : -1
if (index > -1) {
return name.substring(index + 1, name.length).toLowerCase()
// 这里不用split('.').pop()因为没有后缀时会返回自身
const index = name.lastIndexOf('.')
if (index > 0) {
return name.substring(index + 1).toLowerCase()

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected indentation of 8 spaces but found 10

Check failure on line 399 in packages/upload/src/upload.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected indentation of 8 spaces but found 10
}
return ''
}
Expand Down

0 comments on commit 96cc33a

Please sign in to comment.