diff --git a/.gitignore b/.gitignore index da23d0d..52eedce 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ build/Release # Deployed apps should consider commenting this line out: # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git node_modules + +# jetbrain related directories/files +.idea/ diff --git a/index.js b/index.js index 2e97163..06943f7 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,10 @@ function mdls(file, args, ready) { if (typeof args !== 'string') { ready = args; } - file = path.resolve(file).replace(/ /g, '\\ ') + file = path.resolve(file) + .replace(/ /g, '\\ ') + .replace(/\(/g, '\\(') + .replace(/\)/g, '\\)') return new Promise((resolve, reject) => { exec('mdls ' + (args ? args + ' ' : '') + file, function(err, raw_data) { @@ -77,11 +80,17 @@ function to_js_type(key) { const as_date = new Date(value) - if(isNaN(as_date.getTime())) { - bad_value(key, value) + if(!isNaN(as_date.getTime())) { + return as_date } - return as_date + // handle cases like `("H.264",AAC)` where AAC doesn't + // get wrapped with double-quotes + if (/[a-zA-Z]+/.test(value)) { + return value + } + + bad_value(key, value) } }