mirror of
https://github.com/badges/shields.git
synced 2025-04-18 19:44:04 +03:00
Redirect an old png badge with a number as a color; test on [static] (#3412)
Fixes https://github.com/badges/shields/issues/3260
Problem happens when a value of a color in an old PNG static badge is a number: http://localhost:8080/my-label/my-message.png?color=1. In this case `color` in `queryParams` is a number.
0a0b5b3f03/core/server/server.js (L203-L212)
Surprisingly service test listed below is passing currently on master - value `1` is represented in `queryParams` as a String (only in test).
`services/static-badge/static-badge.tester.js`
```js
t.create('Old static badge with a number as a color')
.get('/foo/bar.png?color=1', { followRedirect: false })
.expectStatus(301)
.expectHeader('Location', '/badge/foo-bar-1.png')
```
Moreover I added some code + description allowing to debug server.
This commit is contained in:
parent
7afb26ef14
commit
283601423f
13
.vscode/launch.json
vendored
Normal file
13
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Node: Nodemon",
|
||||
"processId": "${command:PickProcess}",
|
||||
"restart": true,
|
||||
"protocol": "inspector"
|
||||
}
|
||||
]
|
||||
}
|
@ -111,6 +111,9 @@ To debug a badge from the command line, run `npm run badge -- /npm/v/nock.svg`.
|
||||
It also works with full URLs like
|
||||
`npm run badge -- https://img.shields.io/npm/v/nock.svg`.
|
||||
|
||||
Use `npm run debug:server` to start server in debug mode.
|
||||
[This recipe][nodemon debug] shows how to debug Node.js application in [VS Code][].
|
||||
|
||||
Shields has experimental support for [Gitpod Beta][gitpod], a pre-configured development
|
||||
environment that runs in your browser. To use Gitpod, click the button below and
|
||||
sign in with GitHub. Gitpod also offers a browser add-on, though it is not required.
|
||||
@ -137,6 +140,8 @@ Daily tests, including a full run of the service tests and overall code coverage
|
||||
[sentry configuration]: doc/self-hosting.md#sentry
|
||||
[daily-tests]: https://github.com/badges/daily-tests
|
||||
[nodemon]: https://nodemon.io/
|
||||
[nodemon debug]: https://github.com/Microsoft/vscode-recipes/tree/master/nodemon
|
||||
[vs code]: https://code.visualstudio.com/
|
||||
|
||||
## Hosting your own server
|
||||
|
||||
|
@ -207,7 +207,8 @@ module.exports = class Server {
|
||||
const redirectUrl = staticBadgeUrl({
|
||||
label,
|
||||
message,
|
||||
color,
|
||||
// Fixes https://github.com/badges/shields/issues/3260
|
||||
color: color ? color.toString() : undefined,
|
||||
format: 'png',
|
||||
})
|
||||
|
||||
|
@ -107,6 +107,7 @@
|
||||
"now-start": "npm run start:server:prod",
|
||||
"start:server:e2e-on-build": "node server 8080",
|
||||
"start:server": "cross-env NODE_CONFIG_ENV=development nodemon server 8080",
|
||||
"debug:server": "cross-env NODE_CONFIG_ENV=development nodemon --inspect server.js 8080",
|
||||
"prestart": "run-s --silent depcheck defs features",
|
||||
"start": "concurrently --names server,frontend \"npm run start:server\" \"cross-env GATSBY_BASE_URL=http://localhost:8080 gatsby develop --port 3000\"",
|
||||
"e2e": "start-server-and-test start http://localhost:3000 test:e2e",
|
||||
|
@ -62,3 +62,8 @@ t.create('Old static badge')
|
||||
.get('/foo/bar.png?color=blue', { followRedirect: false })
|
||||
.expectStatus(301)
|
||||
.expectHeader('Location', '/badge/foo-bar-blue.png')
|
||||
|
||||
t.create('Old static badge without a color')
|
||||
.get('/foo/bar.png', { followRedirect: false })
|
||||
.expectStatus(301)
|
||||
.expectHeader('Location', '/badge/foo-bar-lightgray.png')
|
||||
|
Loading…
x
Reference in New Issue
Block a user