MCPcopy
hub / github.com/moxiecode/plupload / normalizeOption

Function normalizeOption

js/plupload.dev.js:4156–4268  ·  view source on GitHub ↗

Normalize an option. @method normalizeOption @private @param {String} option Name of the option to normalize @param {Mixed} value @param {Object} options The whole set of options, that might be modified during normalization (see max_file_size or unique_names)!

(option, value, options)

Source from the content-addressed store, hash-verified

4154 @param {Object} options The whole set of options, that might be modified during normalization (see max_file_size or unique_names)!
4155 */
4156 function normalizeOption(option, value, options) {
4157 switch (option) {
4158
4159 case 'chunk_size':
4160 if (value = plupload.parseSize(value)) {
4161 options.send_file_name = true;
4162 }
4163 break;
4164
4165 case 'headers':
4166 var headers = {};
4167 if (typeof(value) === 'object') {
4168 plupload.each(value, function(value, key) {
4169 headers[key.toLowerCase()] = value;
4170 });
4171 }
4172 return headers;
4173
4174 case 'http_method':
4175 return value.toUpperCase() === 'PUT' ? 'PUT' : 'POST';
4176
4177
4178 case 'filters':
4179 if (plupload.typeOf(value) === 'array') { // for backward compatibility
4180 value = {
4181 mime_types: value
4182 };
4183 }
4184
4185 // if file format filters are being updated, regenerate the matching expressions
4186 if (value.mime_types) {
4187 if (plupload.typeOf(value.mime_types) === 'string') {
4188 value.mime_types = plupload.mimes2extList(value.mime_types);
4189 }
4190
4191 // generate and cache regular expression for filtering file extensions
4192 options.re_ext_filter = (function(filters) {
4193 var extensionsRegExp = [];
4194
4195 plupload.each(filters, function(filter) {
4196 plupload.each(filter.extensions.split(/,/), function(ext) {
4197 if (/^\s*\*\s*$/.test(ext)) {
4198 extensionsRegExp.push('\\.*');
4199 } else {
4200 extensionsRegExp.push('\\.' + ext.replace(new RegExp('[' + ('/^$.*+?|()[]{}\\'.replace(/./g, '\\$&')) + ']', 'g'), '\\$&'));
4201 }
4202 });
4203 });
4204
4205 return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i');
4206 }(value.mime_types));
4207 }
4208
4209 return value;
4210
4211 case 'max_file_size':
4212 if (options && !options.filters) {
4213 options.filters = {};

Callers 2

UploaderFunction · 0.70
normalizeOptionsFunction · 0.70

Calls 1

normalizeCapsFunction · 0.70

Tested by

no test coverage detected