Browse Source

Fix URL bug

Specify URL for querying in shields.
master
TheoryOfNekomata 3 years ago
parent
commit
f666805425
3 changed files with 6 additions and 3 deletions
  1. +4
    -1
      getBadgeUrl.js
  2. +1
    -1
      index.js
  3. +1
    -1
      loadBrands.js

+ 4
- 1
getBadgeUrl.js View File

@@ -1,3 +1,4 @@
const path = require('path')
const RESOLVE = require('./resolve.json')
const loadBrands = require('./loadBrands')
const getLibraryColor = require('./getLibraryColor')
@@ -27,6 +28,7 @@ module.exports = async ({
label: repo,
style,
labelColor,
url: new URL(path.join(repo, 'raw', 'branch', process.env.MAIN_BRANCH, 'package.json'), process.env.REPO_BASE_URL),
}).toString()
return badgeUrl
case 'dependency':
@@ -42,7 +44,8 @@ module.exports = async ({
logo: libraryInfo.name,
logoColor,
style,
})
url: new URL(path.join(repo, 'raw', 'branch', process.env.MAIN_BRANCH, 'package.json'), process.env.REPO_BASE_URL),
}).toString()
return badgeUrl
default:
break


+ 1
- 1
index.js View File

@@ -30,7 +30,7 @@ const server = http.createServer(async (req, res) => {

const response = await axios({
method: 'GET',
url: badgeUrl,
url: badgeUrl.toString(),
responseType: 'stream'
})
res.writeHead(200, { 'content-type': 'image/svg+xml', })


+ 1
- 1
loadBrands.js View File

@@ -38,7 +38,7 @@ const fetchBrands = () => new Promise(async (resolve, reject) => {

module.exports = () => new Promise((resolve, reject) => {
fs.readFile(process.env.BRANDS_JSON_FILE_PATH, async (err, file) => {
if (err.code === 'ENOENT') {
if (err && err.code === 'ENOENT') {
const result = await fetchBrands()
resolve(result)
return


Loading…
Cancel
Save