Skip to content

Commit

Permalink
Add support for new names
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Jul 15, 2019
1 parent 647ac7f commit d13161e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mapNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function createDateName (match) {
}

module.exports = function mapName (fileName) {
const collectionPattern = /^(?:(?<collection>Sm|DT|Rm|Rm 2|Rm II|BM) )?(?<number>\d+)\.csv$/
const collectionPattern = /^(?:(?<collection>Sm|DT|Rm|Rm 2|Rm II|BM|CBS|N|UM) )?(?<number>\d+)\.csv$/
const collectionMatch = collectionPattern.exec(fileName)
const datePattern = /^(?<year>\d{2})-(?<month>\d{1,2})-(?<day>\d{1,2})[ ,](?<number>\d+)\.csv$/
const dateMatch = datePattern.exec(fileName)
Expand Down
3 changes: 3 additions & 0 deletions lib/mapNames.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d13161e

Please sign in to comment.