diff --git a/lib/install.js b/lib/install.js index 82705428..6c4d5c63 100644 --- a/lib/install.js +++ b/lib/install.js @@ -11,7 +11,6 @@ const existsAsync = fs.exists || path.exists; const versioning = require('./util/versioning.js'); const napi = require('./util/napi.js'); const s3_setup = require('./util/s3_setup.js'); -const url = require('url'); // for fetching binaries const fetch = require('node-fetch'); const tar = require('tar'); @@ -38,7 +37,7 @@ function place_binary_authenticated(opts, targetDir, callback) { try { const config = s3_setup.detect(opts); const s3 = s3_setup.get_s3(config); - const key_name = url.resolve(config.prefix, opts.package_name); + const key_name = path.posix.join(config.prefix, opts.package_name); log.info('install', 'Downloading from S3:', config.bucket, key_name); diff --git a/lib/publish.js b/lib/publish.js index 23ef53b8..0c38f812 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -11,7 +11,6 @@ const versioning = require('./util/versioning.js'); const napi = require('./util/napi.js'); const s3_setup = require('./util/s3_setup.js'); const existsAsync = fs.exists || path.exists; -const url = require('url'); function publish(gyp, argv, callback) { const package_json = gyp.package_json; @@ -27,7 +26,7 @@ function publish(gyp, argv, callback) { const config = s3_setup.detect(opts); const s3 = s3_setup.get_s3(config); - const key_name = url.resolve(config.prefix, opts.package_name); + const key_name = path.posix.join(config.prefix, opts.package_name); const s3_opts = { Bucket: config.bucket, Key: key_name diff --git a/lib/unpublish.js b/lib/unpublish.js index cb198e39..94403d0c 100644 --- a/lib/unpublish.js +++ b/lib/unpublish.js @@ -8,7 +8,7 @@ const log = require('./util/log.js'); const versioning = require('./util/versioning.js'); const napi = require('./util/napi.js'); const s3_setup = require('./util/s3_setup.js'); -const url = require('url'); +const path = require('path'); function unpublish(gyp, argv, callback) { const package_json = gyp.package_json; @@ -16,7 +16,7 @@ function unpublish(gyp, argv, callback) { const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version); const config = s3_setup.detect(opts); const s3 = s3_setup.get_s3(config); - const key_name = url.resolve(config.prefix, opts.package_name); + const key_name = path.posix.join(config.prefix, opts.package_name); const s3_opts = { Bucket: config.bucket, Key: key_name diff --git a/lib/util/s3_setup.js b/lib/util/s3_setup.js index ccbfa74e..f4df4e29 100644 --- a/lib/util/s3_setup.js +++ b/lib/util/s3_setup.js @@ -2,13 +2,11 @@ module.exports = exports; -const url = require('url'); - module.exports.detect = function(opts) { const config = {}; const to = opts.hosted_path; - const uri = url.parse(to); + const uri = new URL(to); if (opts.bucket && opts.region) { // use user defined settings for host, region, bucket diff --git a/lib/util/versioning.js b/lib/util/versioning.js index b69b367e..83f5d02c 100644 --- a/lib/util/versioning.js +++ b/lib/util/versioning.js @@ -4,7 +4,6 @@ module.exports = exports; const path = require('path'); const semver = require('semver'); -const url = require('url'); const detect_libc = require('detect-libc'); const napi = require('./napi.js'); @@ -221,7 +220,7 @@ function validate_config(package_json, opts) { } if (o) { // enforce https over http - const protocol = url.parse(o.host).protocol; + const protocol = new URL(o.host).protocol; if (protocol === 'http:') { throw new Error("'host' protocol (" + protocol + ") is invalid - only 'https:' is accepted"); } @@ -333,10 +332,10 @@ module.exports.evaluate = function(package_json, options, napi_build_version) { // when using s3ForcePathStyle the bucket is part of the http object path // add it if (opts.s3ForcePathStyle) { - opts.hosted_path = url.resolve(opts.host, drop_double_slashes(`${opts.bucket}/${opts.remote_path}`)); + opts.hosted_path = new URL(drop_double_slashes(`${opts.bucket}/${opts.remote_path}`), opts.host).href; } else { - opts.hosted_path = url.resolve(opts.host, opts.remote_path); + opts.hosted_path = new URL(opts.remote_path, opts.host).href; } - opts.hosted_tarball = url.resolve(opts.hosted_path, opts.package_name); + opts.hosted_tarball = new URL(opts.package_name, opts.hosted_path).href; return opts; }; diff --git a/package.json b/package.json index 8fa9d3f4..a9eda4a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "@mapbox/node-pre-gyp", + "name": "@yrambler2001/node-pre-gyp", "description": "Node.js native addon binary install tool", - "version": "2.0.4-pre.0", + "version": "2.0.4", "keywords": [ "native", "addon",