diff --git a/src/clean-context.js b/src/clean-context.js index a5d5de2..baa62b2 100644 --- a/src/clean-context.js +++ b/src/clean-context.js @@ -4,14 +4,18 @@ * @param {Object} context */ module.exports = context => { + const cleanBadgeText = text => text.replace(/-/g, '--').replace(/_/g, '__') + // Why doing this? // See https://github.com/kefranabg/readme-md-generator/pull/141 const licenseName = context.licenseName .replace(/-/g, '--') .replace(/_/g, '__') + const projectVersion = cleanBadgeText(context.projectVersion) return { ...context, - licenseName + licenseName, + projectVersion } } diff --git a/src/clean-context.spec.js b/src/clean-context.spec.js index c245f0c..8b8a6ad 100644 --- a/src/clean-context.spec.js +++ b/src/clean-context.spec.js @@ -1,9 +1,15 @@ const cleanContext = require('./clean-context') describe('cleanContext', () => { - it('should replace licenseName - and _ characters by -- and __', () => { - const context = { licenseName: 'Apache-2_0' } - const cleanedContext = { licenseName: 'Apache--2__0' } + it('should replace licenseName and projectVersion - and _ characters by -- and __', () => { + const context = { + licenseName: 'Apache-2_0', + projectVersion: '1.0_0-alpha' + } + const cleanedContext = { + licenseName: 'Apache--2__0', + projectVersion: '1.0__0--alpha' + } const result = cleanContext(context)