kopia lustrzana https://github.com/badgen/badgen
Merge branch 'master' into emoji
commit
52cc8bb198
|
@ -3,7 +3,7 @@ const badgen = require('..')
|
|||
|
||||
const longParams = { subject: 'build-build-build', status: 'passing-passing-passing' }
|
||||
const fullParams = { subject: 'license', status: 'MIT', color: 'cyan' }
|
||||
const emojiParams = { subject: 'emojis', status: '💩🤱🦄' }
|
||||
const emojiParams = { subject: 'emojis', status: '💩🤱🦄', color: 'cyan' }
|
||||
|
||||
new Suite()
|
||||
.add('[classic] style, long params ', () => badgen(longParams))
|
||||
|
|
|
@ -4588,9 +4588,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"serve-marked": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/serve-marked/-/serve-marked-0.0.1.tgz",
|
||||
"integrity": "sha512-2SG8gKKcl9RZE6SEKj2Tm2d+FnF28JRSFZ7fLCkjgPKIb7WslFiqoBi0YG/RtkVSb2vXKOSnCXwmxPi+4JbZvw==",
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/serve-marked/-/serve-marked-0.2.0.tgz",
|
||||
"integrity": "sha512-BkFgYKzajiR2Knx8mvQSWY6Z7npNKakw6qWjJNTVWGEa+68gWLdXnS5scwGK7+T0G48Q043jv7PweVxW8AigAw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"marked": "^0.4.0"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name": "badgen",
|
||||
"version": "2.0.0",
|
||||
"description": "Fast svg badge generator.",
|
||||
"repository": "amio/badgen",
|
||||
"author": "Amio <amio.cn@gmail.com>",
|
||||
"license": "ISC",
|
||||
"main": "lib/index.js",
|
||||
|
@ -10,11 +11,11 @@
|
|||
"bench": "node bench/index.js",
|
||||
"preview": "node preview/serve.js",
|
||||
"pretest": "npm run lint",
|
||||
"test": "tap test/*.spec.js --reporter spec"
|
||||
"test": "tap test/*.spec.js --reporter spec --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"serve-marked": "0.0.1",
|
||||
"serve-marked": "0.2.0",
|
||||
"standard": "^11.0.1",
|
||||
"tap": "^12.0.1"
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
|
||||
| Badge (flat) | URL |
|
||||
| --- | --- |
|
||||
| | [/chat/gitter/cyan/flat](/chat/gitter/cyan/flat) |
|
||||
| | [/style/standard/f2a/flat](/style/standard/f2a/flat) |
|
||||
| | [/license/Apache-2.0/blue/flat](/license/Apache-2.0/blue/flat) |
|
||||
| | [/Language/Swift%203.0.1/orange/flat](/Language/Swift%203.0.1/orange/flat) |
|
||||
| | [/chat/gitter/cyan?style=flat](/chat/gitter/cyan?style=flat) |
|
||||
| | [/style/standard/f2a?style=flat](/style/standard/f2a?style=flat) |
|
||||
| | [/license/Apache-2.0/blue?style=flat](/license/Apache-2.0/blue?style=flat) |
|
||||
| | [/Language/Swift%203.0.1/orange?style=flat](/Language/Swift%203.0.1/orange?style=flat) |
|
||||
|
||||
## Multibytes unicode
|
||||
|
||||
| Badge | URL |
|
||||
| --- | --- |
|
||||
| | [/emoji/💩🤱🦄/cyan/flat?unicode=1](/emoji/💩🤱🦄/cyan/flat?unicode=1) |
|
||||
| | [/emoji/💩🤱🦄/cyan/?unicode=1](/emoji/💩🤱🦄/cyan/?unicode=1) |
|
||||
| | [/emoji/💩🤱🦄/cyan?style=flat&unicode=1](/emoji/💩🤱🦄/cyan?style=flat&unicode=1) |
|
||||
| | [/emoji/💩🤱🦄/cyan?unicode=1](/emoji/💩🤱🦄/cyan?unicode=1) |
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const http = require('http')
|
||||
const path = require('path')
|
||||
const url = require('url')
|
||||
const qs = require('querystring')
|
||||
const serveMarked = require('serve-marked')
|
||||
const badgen = require('..')
|
||||
|
@ -7,8 +8,9 @@ const badgen = require('..')
|
|||
// @example
|
||||
// http://localhost:3000/npm/v1.2.3
|
||||
const serveBadge = (req, res) => {
|
||||
const unicode = Boolean(qs.parse(req.url.split('?')[1]).unicode)
|
||||
const [ subject, status, color, style ] = req.url.split('/')
|
||||
const { pathname, query } = url.parse(req.url)
|
||||
const { style, unicode } = qs.parse(query)
|
||||
const [ subject, status, color ] = pathname.split('/')
|
||||
.filter(Boolean)
|
||||
.map(s => qs.unescape(s))
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue