Skip to content

Commit

Permalink
fix: add electron user agent header to fetch calls
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypicalpro committed Aug 22, 2020
1 parent dfe62cd commit 24a7202
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const enum Inputs {
CUR_BRANCH = 'current_branch'
}

// An Electron 2.0 running on Linux, so shields.io doesn't block us
const USER_AGENT =
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/3.4.1 Chrome/61.0.3163.100 Electron/2.0.18 Safari/537.36'

/**
* Scans a markdown document for blocks denotated by a specific markdown comment
* (<!-- badge-compile -->) and extracts all markdown image links from that
Expand Down Expand Up @@ -113,7 +117,11 @@ export async function fetchAndWriteBadge(
): Promise<string | null> {
let res
try {
res = await fetch(url)
res = await fetch(url, {
headers: {
'User-Agent': USER_AGENT
}
})
} catch (e) {
core.warning(`Fetching badge ${url} failed with error ${e.toString()}`)
return null
Expand Down

0 comments on commit 24a7202

Please sign in to comment.