mirror of
https://github.com/goreleaser/goreleaser-action
synced 2026-07-08 18:17:30 +00:00
Remove absolute paths
This commit is contained in:
+3
-23
@@ -1,8 +1,7 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const caw = require('caw');
|
||||
const {URL} = require('url');
|
||||
const contentDisposition = require('content-disposition');
|
||||
const archiveType = require('archive-type');
|
||||
const decompress = require('decompress');
|
||||
@@ -16,7 +15,7 @@ const fileType = require('file-type');
|
||||
const extName = require('ext-name');
|
||||
|
||||
const fsP = pify(fs);
|
||||
const filenameFromPath = res => path.basename(url.parse(res.requestUrl).pathname);
|
||||
const filenameFromPath = res => path.basename(new URL(res.requestUrl).pathname);
|
||||
|
||||
const getExtFromMime = res => {
|
||||
const header = res.headers['content-type'];
|
||||
@@ -58,37 +57,18 @@ const getFilename = (res, data) => {
|
||||
return filename;
|
||||
};
|
||||
|
||||
const getProtocolFromUri = uri => {
|
||||
let {protocol} = url.parse(uri);
|
||||
|
||||
if (protocol) {
|
||||
protocol = protocol.slice(0, -1);
|
||||
}
|
||||
|
||||
return protocol;
|
||||
};
|
||||
|
||||
module.exports = (uri, output, opts) => {
|
||||
if (typeof output === 'object') {
|
||||
opts = output;
|
||||
output = null;
|
||||
}
|
||||
|
||||
const protocol = getProtocolFromUri(uri);
|
||||
|
||||
opts = Object.assign({
|
||||
encoding: null,
|
||||
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false'
|
||||
}, opts);
|
||||
|
||||
const agent = caw(opts.proxy, {protocol});
|
||||
const stream = got.stream(uri, Object.assign({agent}, opts))
|
||||
.on('redirect', (response, nextOptions) => {
|
||||
const redirectProtocol = getProtocolFromUri(nextOptions.href);
|
||||
if (redirectProtocol && redirectProtocol !== protocol) {
|
||||
nextOptions.agent = caw(opts.proxy, {protocol: redirectProtocol});
|
||||
}
|
||||
});
|
||||
const stream = got.stream(uri, opts);
|
||||
|
||||
const promise = pEvent(stream, 'response').then(res => {
|
||||
const encoding = opts.encoding === null ? 'buffer' : opts.encoding;
|
||||
|
||||
Reference in New Issue
Block a user