Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic badge generator generates wrong URL #1339

Closed
valeth opened this issue Dec 6, 2017 · 7 comments
Closed

Dynamic badge generator generates wrong URL #1339

valeth opened this issue Dec 6, 2017 · 7 comments
Labels
bug Bugs in badges and the frontend frontend The Docusaurus app serving the docs site

Comments

@valeth
Copy link

valeth commented Dec 6, 2017

When I tried to use the dynamic badge creator here the inputted URL in the uri field generated a wrong URL containing two dashes (some--path) instead of one (some-path).

Manually correcting the URL fixes this.

The parameters used were:

type:      json
label:     UserScript
uri:       https://gitlab.com/valeth/wanikani-lesson-cap/raw/master/package.json
path:      $.version
hex color: <default>
prefix:    v
suffix:    <default>

Result:
badge
https://img.shields.io/badge/dynamic/json.svg?label=UserScript&colorB=&prefix=v&suffix=&query=$.version&uri=https%3A%2F%2Fgitlab.com%2Fvaleth%2Fwanikani--lesson--cap%2Fraw%2Fmaster%2Fpackage.json

Fixed (and working) version:
badge
https://img.shields.io/badge/dynamic/json.svg?label=UserScript&colorB=&prefix=v&suffix=&query=$.version&uri=https%3A%2F%2Fgitlab.com%2Fvaleth%2Fwanikani-lesson-cap%2Fraw%2Fmaster%2Fpackage.json

@tooomm
Copy link
Contributor

tooomm commented Dec 6, 2017

@paulmelnikow
Copy link
Member

Is this fixed in the new frontend on staging?

https://shields-staging.herokuapp.com

@paulmelnikow paulmelnikow added bug Bugs in badges and the frontend frontend The Docusaurus app serving the docs site labels Dec 6, 2017
@tooomm
Copy link
Contributor

tooomm commented Dec 6, 2017

Well, it looks to be completely broken there (waited for full load). 😆
The Make Badge button won't work at all and in the type field at the beginning there is always "json" displayed. You also can't remove that. :)

@paulmelnikow
Copy link
Member

Ah, yes, on staging the URL is missing /badge before /dynamic. Can you confirm it's working otherwise?

We could remove that json field, and change url to json url. It was done that way it is because @RedSparr0w wants to add a dynamic XML badge.

@tooomm
Copy link
Contributor

tooomm commented Dec 6, 2017

We could remove that json field, and change url to json url. It was done that way it is because @RedSparr0w wants to add a dynamic XML badge.

Oh, I thought xml is working already. I really like additional options like xml or yml/yaml!

Ah, yes, on staging the URL is missing /badge before /dynamic. Can you confirm it's working otherwise?

Looking at the code I realized that the button gets only enabled if you fill out certain information...
After clicking it and adding in /badge it works! No doubled -.

@paulmelnikow
Copy link
Member

Proposed fix: #1344

@chris48s
Copy link
Member

chris48s commented Oct 6, 2018

The dynamic json badge dynamic/json.svg is expecting the response from URL to be JSON but http://simpleicons.org/icons/protonmail.svg is SVG which is why an error is thrown trying to parse it as JSON. URL should return the data you want to parse and the query param describes how to extract the value from the JSON response. Here's a concrete usage example:

https://img.shields.io/badge/dynamic/json.svg?url=https://github.com/badges/shields/raw/master/package.json&query=$.name&label=Package%20Name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend frontend The Docusaurus app serving the docs site
Projects
None yet
Development

No branches or pull requests

4 participants