diff --git a/scripts/utils/metadata.js b/scripts/utils/metadata.js index 7af6fb1..bd9e587 100644 --- a/scripts/utils/metadata.js +++ b/scripts/utils/metadata.js @@ -1,4 +1,6 @@ -const titleSuffixPattern = /^(.+)\s-\s+adaptTo\(\)\s+\d+\s*$/; +// match e.g. with " - adaptTo() 2023" +// but also with ", adaptTo() 2023" which seems to be generated sometimes due to a bug +const titleSuffixPattern = /^(.+)(\s-|,)\s+adaptTo\(\)\s+\d+\s*$/; /** * Splits a comma-separated value to array (trimming the values). diff --git a/test/scripts/utils/metadata.test.js b/test/scripts/utils/metadata.test.js index d681096..94c864b 100644 --- a/test/scripts/utils/metadata.test.js +++ b/test/scripts/utils/metadata.test.js @@ -22,6 +22,7 @@ describe('utils/metadata', () => { it('removeTitleSuffix', () => { expect(removeTitleSuffix('My Title - adaptTo() 2021')).to.eq('My Title'); + expect(removeTitleSuffix('My Title, adaptTo() 2021')).to.eq('My Title'); expect(removeTitleSuffix('My Title - Second One - adaptTo() 2020 ')).to.eq('My Title - Second One'); expect(removeTitleSuffix('adaptTo() 2021')).to.eq('adaptTo() 2021'); expect(removeTitleSuffix('')).to.eq('');