mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:35:15 +08:00
FIX: improves UI state when no extensions are allowed for upload
This commit is contained in:
@ -193,6 +193,8 @@ export function validateUploadedFiles(files, opts) {
|
||||
}
|
||||
|
||||
export function validateUploadedFile(file, opts) {
|
||||
if (!authorizesOneOrMoreExtensions()) return false;
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
const name = file && file.name;
|
||||
@ -277,6 +279,21 @@ export function authorizesAllExtensions() {
|
||||
return Discourse.SiteSettings.authorized_extensions.indexOf("*") >= 0;
|
||||
}
|
||||
|
||||
export function authorizesOneOrMoreExtensions() {
|
||||
if (authorizesAllExtensions()) return true;
|
||||
|
||||
return Discourse.SiteSettings.authorized_extensions
|
||||
.split("|")
|
||||
.filter(ext => ext)
|
||||
.length > 0;
|
||||
}
|
||||
|
||||
export function authorizesOneOrMoreImageExtensions() {
|
||||
if (authorizesAllExtensions()) return true;
|
||||
|
||||
return imagesExtensions().length > 0;
|
||||
}
|
||||
|
||||
export function isAnImage(path) {
|
||||
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)$/i).test(path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user