-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
saqqdy
committed
Sep 3, 2021
1 parent
af088cf
commit 2d3a4cd
Showing
10 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
/** | ||
* 文件后缀名 | ||
* | ||
* @example | ||
* ```js | ||
* getFileType('http://www.saqqdy.com/test.jpg'); // .jpg; | ||
* ``` | ||
* @example | ||
* ```js | ||
* getFileType('http://www.saqqdy.com/test.JPEG'); // .jpeg; | ||
* ``` | ||
* @param url - 文件名 | ||
* @returns 返回文件后缀 | ||
*/ | ||
function getFileType(url: string): string | null { | ||
function getFileType(url: string): string { | ||
if (typeof url != 'string' || url == '') { | ||
return null | ||
return '' | ||
} | ||
var type = /\.[^\.]+$/.exec(url) //[".docx", index: 31, input: "http://192.168.2.243:7005/doc/2.docx"] | ||
return type ? type[0].toLowerCase() : null | ||
var type = /\.[^\.]+$/.exec(url) // [".docx", index: 31, input: "http://192.168.2.243:7005/doc/2.docx"] | ||
return type ? type[0].toLowerCase() : '' | ||
} | ||
|
||
export default getFileType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters