FIX: properly detect when attachments are allowed
This commit is contained in:
parent
c6ef1301f3
commit
9f7b529495
|
@ -267,12 +267,12 @@ export function isAnImage(path) {
|
|||
|
||||
export function allowsImages() {
|
||||
return authorizesAllExtensions() ||
|
||||
(/(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)/i).test(authorizedExtensions());
|
||||
(/\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)/i).test(authorizedExtensions());
|
||||
}
|
||||
|
||||
export function allowsAttachments() {
|
||||
return authorizesAllExtensions() ||
|
||||
!(/((png|jpe?g|gif|bmp|tiff?|svg|web|ico)(,\s)?)+$/i).test(authorizedExtensions());
|
||||
!/^(\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)(,\s)?)+$/i.test(authorizedExtensions());
|
||||
}
|
||||
|
||||
export function displayErrorForUpload(data) {
|
||||
|
|
|
@ -164,13 +164,13 @@ test("avatarImg", function() {
|
|||
});
|
||||
|
||||
test("allowsAttachments", function() {
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
Discourse.SiteSettings.authorized_extensions = ".jpg, .jpeg, .gif";
|
||||
not(allowsAttachments(), "no attachments allowed by default");
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif|*";
|
||||
Discourse.SiteSettings.authorized_extensions = ".jpg, .jpeg, .gif, *";
|
||||
ok(allowsAttachments(), "attachments are allowed when all extensions are allowed");
|
||||
|
||||
Discourse.SiteSettings.authorized_extensions = "jpg|jpeg|gif|pdf";
|
||||
Discourse.SiteSettings.authorized_extensions = ".jpg, .jpeg, .gif, .pdf";
|
||||
ok(allowsAttachments(), "attachments are allowed when at least one extension is not an image extension");
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue