'use strict';

const common = module.exports = {};

common.getBasename = function (filename) {
    let base = filename.replace(/.*\//, '');
    return base.replace(/\.[0-9]+$/, '');
};

common.getExtension = function (filename) {
    let extension = common.getBasename(filename);
    return extension.replace(/.*\./, '').toLowerCase();
};


common.getFilename = function (typeEntry) {
    let keys = Object.keys(typeEntry);
    for (let i = 0; i < keys.length; i++) {
        if (typeEntry[keys[i]] && typeEntry[keys[i]].filename) {
            return typeEntry[keys[i]].filename;
        }
    }
};

common.basenameFind = function (typeEntries, filename) {
    let reference = common.getBasename(filename);

    return typeEntries.find(typeEntry => {
        return common.getBasename(common.getFilename(typeEntry)) === reference;
    });
};

common.getTargetProperty = function (filename) {
    switch (common.getExtension(filename)) {
        case 'jdx':
        case 'dx':
        case 'jcamp':
            return 'jcamp';
        case 'png':
        case 'jpg':
        case 'jpeg':
        case 'tif':
        case 'tiff':
            return 'image';
        case 'cif':
            return 'cif';
        case 'pdb':
            return 'pdb';
        case 'xml':
            return 'xml';
        case 'cdf':
        case 'netcdf':
            return 'cdf';
        case 'pdf':
            return 'pdf';
        default :
            return 'file'
    }
};
@@ -1304,24 +1304,43 @@
 case 'cdf':%0A
+        case 'nc':%0A
         case
@@ -1466,16 +1466,17 @@
  'file'%0A    %7D%0A%7D;
+%0A

add nc to netCDF