Skip to content

Commit

Permalink
Fix regression with double-dash escaping in [StaticBadge] (#2367)
Browse files Browse the repository at this point in the history
Fix #2366
  • Loading branch information
paulmelnikow authored Nov 19, 2018
1 parent 6305c59 commit b922fca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion services/static-badge/static-badge.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const BaseStaticService = require('../base-static')
const { escapeFormat } = require('../../lib/path-helpers')

module.exports = class StaticBadge extends BaseStaticService {
static get category() {
Expand All @@ -15,6 +16,6 @@ module.exports = class StaticBadge extends BaseStaticService {
}

handle({ label, message, color }) {
return { label, message, color }
return { label: escapeFormat(label), message: escapeFormat(message), color }
}
}
8 changes: 8 additions & 0 deletions services/static-badge/static-badge.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ t.create('Missing label')
.get('/badge/-message-blue.json?style=_shields_test')
.expectJSON({ name: '', value: 'message', colorB: '#007ec6' })

t.create('Case is preserved')
.get('/badge/LiCeNsE-mIt-blue.json?style=_shields_test')
.expectJSON({ name: 'LiCeNsE', value: 'mIt', colorB: '#007ec6' })

t.create('"Shields-encoded" dash')
.get('/badge/best--license-Apache--2.0-blue.json?style=_shields_test')
.expectJSON({ name: 'best-license', value: 'Apache-2.0', colorB: '#007ec6' })

t.create('Override colorB')
.get('/badge/label-message-blue.json?style=_shields_test&colorB=yellow')
.expectJSON({ name: 'label', value: 'message', colorB: '#dfb317' })
Expand Down

0 comments on commit b922fca

Please sign in to comment.