From d13161e07ad8998a44b56031f9f274e39282083a Mon Sep 17 00:00:00 2001 From: Jussi Laasonen Date: Mon, 15 Jul 2019 08:08:02 +0200 Subject: [PATCH] Add support for new names --- lib/mapNames.js | 2 +- lib/mapNames.test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mapNames.js b/lib/mapNames.js index fd86d6c..185d5c4 100644 --- a/lib/mapNames.js +++ b/lib/mapNames.js @@ -23,7 +23,7 @@ function createDateName (match) { } module.exports = function mapName (fileName) { - const collectionPattern = /^(?:(?Sm|DT|Rm|Rm 2|Rm II|BM) )?(?\d+)\.csv$/ + const collectionPattern = /^(?:(?Sm|DT|Rm|Rm 2|Rm II|BM|CBS|N|UM) )?(?\d+)\.csv$/ const collectionMatch = collectionPattern.exec(fileName) const datePattern = /^(?\d{2})-(?\d{1,2})-(?\d{1,2})[ ,](?\d+)\.csv$/ const dateMatch = datePattern.exec(fileName) diff --git a/lib/mapNames.test.js b/lib/mapNames.test.js index df4afea..11207ca 100644 --- a/lib/mapNames.test.js +++ b/lib/mapNames.test.js @@ -15,6 +15,9 @@ test.each` ${'63-2-9,123.csv'} | ${'1863,0209.123'} ${'BM 12345.csv'} | ${'BM.12345'} ${'BM 123456.csv'} | ${'BM.123456'} + ${'CBS 123456.csv'} | ${'CBS.123456'} + ${'N 123456.csv'} | ${'N.123456'} + ${'UM 123456.csv'} | ${'UM.123456'} ${'invalid.xlsx'} | ${null} `('returns $fragmentId for $fileName', ({ fileName, fragmentId }) => { expect(mapNames(fileName)).toBe(fragmentId)