import _ from 'underscore';

import { settings } from '../../settings';

export const fileUploadMediaWhiteList = function() {
	const mediaTypeWhiteList = settings.get('FileUpload_MediaTypeWhiteList');

	if (!mediaTypeWhiteList || mediaTypeWhiteList === '*') {
		return;
	}
	return _.map(mediaTypeWhiteList.split(','), function(item) {
		return item.trim();
	});
};

export const fileUploadIsValidContentType = function(type) {
	const list = fileUploadMediaWhiteList();
	if (!list) {
		return true;
	}

	if (!type) {
		return false;
	}

	if (_.contains(list, type)) {
		return true;
	}
	const wildCardGlob = '/*';
	const wildcards = _.filter(list, function(item) {
		return item.indexOf(wildCardGlob) > 0;
	});
	if (_.contains(wildcards, type.replace(/(\/.*)$/, wildCardGlob))) {
		return true;
	}

	return false;
};

@@ -115,16 +115,31 @@
 unction(
+customWhiteList
 ) %7B%0A%09con
@@ -161,16 +161,35 @@
 teList =
+ customWhiteList %7C%7C
  setting
@@ -446,24 +446,41 @@
 unction(type
+, customWhiteList
 ) %7B%0A%09const l
@@ -510,16 +510,31 @@
 iteList(
+customWhiteList
 );%0A%09if (

Add custom fileupload whitelist property (#14754)