mirror of
https://github.com/veggiemonk/awesome-docker.git
synced 2025-11-22 16:34:27 +01:00
some improvements (#1030)
* update GitHub Actions > Node.js 12 actions are deprecated. For more information see: > https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. > Please update the following actions to use Node.js 16: actions/checkout, > actions/setup-node, actions/cache, actions/checkout * show location in output if URL is redirected
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
import { isRedirect } from 'node-fetch';
|
||||
import {readFileSync} from 'fs';
|
||||
|
||||
const LINKS_OPTIONS = {
|
||||
redirect: 'error',
|
||||
redirect: 'manual',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'user-agent':
|
||||
@@ -56,8 +57,9 @@ const partition = (arr, func) => {
|
||||
|
||||
async function fetch_link(url) {
|
||||
try {
|
||||
const { ok, statusText, redirected } = await fetch(url, LINKS_OPTIONS);
|
||||
return [url, { ok, status: statusText, redirected }];
|
||||
const { headers, ok, status, statusText } = await fetch(url, LINKS_OPTIONS);
|
||||
const redirect = isRedirect(status) ? { redirect: { src: url, dst: headers.get("location") } } : {};
|
||||
return [url, { ok, status: statusText, ...redirect }];
|
||||
} catch (error) {
|
||||
return [url, { ok: false, status: error.message }];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user