mirror of
https://github.com/labring/FastGPT.git
synced 2026-02-27 01:02:22 +08:00
V4.14.5.1 dev (#6290)
* chore: cherry pick some commits from v4.14.6-dev (#6287) * fix: custom domain limitation (#6265) * fix: system secret (#6259) * fix: system secret * chore: update docs * chore: docs * fix password variable & datetime picker (#6276) * fix password variable & datetime picker * doc * chore: cherry pick some commits from v4.14.6-dev (#6287) * fix: custom domain limitation (#6265) * fix: system secret (#6259) * fix: system secret * chore: update docs * chore: docs * doc * chore: docs --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: Finley Ge <finleyge@fastgpt.io> * perf: extname computed (#6285) * perf: extname computed * chore: handle hash or query flags --------- Co-authored-by: Finley Ge <finleyge@fastgpt.io> * chore: docs (#6291) --------- Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: Archer <545436317@qq.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import crypto from 'crypto';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import path from 'path';
|
||||
|
||||
/* check string is a web link */
|
||||
export function strIsLink(str?: string) {
|
||||
@@ -193,13 +194,14 @@ export const sliceStrStartEnd = (str: string, start: number, end: number) => {
|
||||
=> pdf
|
||||
*/
|
||||
export const parseFileExtensionFromUrl = (url = '') => {
|
||||
// Remove query params
|
||||
const urlWithoutQuery = url.split('?')[0];
|
||||
// Get file name
|
||||
const fileName = urlWithoutQuery.split('/').pop() || '';
|
||||
// Get file extension
|
||||
const extension = fileName.split('.').pop();
|
||||
return (extension || '').toLowerCase();
|
||||
// Remove query params and hash first
|
||||
const urlWithoutQuery = url.split('?')[0].split('#')[0];
|
||||
const extension = path.extname(urlWithoutQuery);
|
||||
// path.extname returns '.ext' or ''
|
||||
if (extension.startsWith('.')) {
|
||||
return extension.slice(1).toLowerCase();
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
export const formatNumberWithUnit = (num: number, locale: string = 'zh-CN'): string => {
|
||||
|
||||
Reference in New Issue
Block a user