Skip to content

Commit fca3979

Browse files
committed
url.URL -> URL
1 parent 931c534 commit fca3979

File tree

7 files changed

+13
-22
lines changed

7 files changed

+13
-22
lines changed

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const url = require('url')
2-
31
const requester = require('./lib/requester')
42
const simpleRequester = require('./lib/simpleRequester')
53
const analysisPoller = require('./lib/analysisPoller')
@@ -34,7 +32,7 @@ class Client {
3432
throw 'Please provide an Ethereum address and a password.'
3533
}
3634

37-
const apiUrl = new url.URL(inputApiUrl)
35+
const apiUrl = new URL(inputApiUrl)
3836
if (!apiUrl.hostname) {
3937
throw new TypeError(`${inputApiUrl} is not a valid URL`)
4038
}
@@ -343,7 +341,7 @@ module.exports.mythXToolUse = (toolNames, inputApiUrl = defaultApiUrl) => {
343341
}
344342

345343
module.exports.Client = Client
346-
module.exports.defaultApiUrl = new url.URL(defaultApiUrl)
344+
module.exports.defaultApiUrl = new URL(defaultApiUrl)
347345
module.exports.defaultApiHost = defaultApiUrl
348346
module.exports.defaultApiVersion = defaultApiVersion
349347
module.exports.defaultInitialDelay = defaultInitialDelay

lib/util.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const url = require('url')
2-
31
/**
42
* Wait for the specified time.
53
*
@@ -10,6 +8,6 @@ exports.timer = async time =>
108
new Promise(resolve => setTimeout(resolve, time))
119

1210
exports.joinUrl = (base, path) => {
13-
const u = new url.URL(path, base)
11+
const u = new URL(path, base)
1412
return u.href
1513
}

test/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const armlet = require('../index')
22
const Client = require('../index').Client
33
const sinon = require('sinon')
4-
const url = require('url')
54
const HttpErrors = require('http-errors')
65
require('chai')
76
.use(require('chai-as-promised'))
@@ -64,7 +63,7 @@ describe('main module', () => {
6463
it('initialize apiUrl to the given value', () => {
6564
const instance = new Client({ ethAddress, password }, apiUrl)
6665

67-
instance.apiUrl.should.be.deep.equal(new url.URL(apiUrl))
66+
instance.apiUrl.should.be.deep.equal(new URL(apiUrl))
6867
})
6968

7069
describe('instances should', () => {
@@ -168,7 +167,7 @@ describe('main module', () => {
168167
describe('functionality', () => {
169168
const uuid = 'analysis-uuid'
170169
const issues = ['issue1', 'issue2']
171-
const parsedApiUrl = new url.URL(apiUrl)
170+
const parsedApiUrl = new URL(apiUrl)
172171
const refreshToken = 'refresh-token'
173172
const accessToken = 'access-token'
174173

test/lib/analysisPoller.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const nock = require('nock')
2-
const url = require('url')
32
const sinon = require('sinon')
43
require('chai')
54
.use(require('chai-as-promised'))
@@ -10,7 +9,7 @@ const util = require('../../lib/util')
109

1110
describe('analysisPoller', () => {
1211
describe('#do', () => {
13-
const apiUrl = new url.URL('https://api.mythx.io')
12+
const apiUrl = new URL('https://api.mythx.io')
1413
const validApiKey = 'valid-api-key'
1514
const uuid = 'my-uuid'
1615
const statusUrl = `/v1/analyses/${uuid}`

test/lib/login.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const nock = require('nock')
2-
const url = require('url')
32
require('chai')
43
.use(require('chai-as-promised'))
54
.should()
@@ -9,7 +8,7 @@ const login = require('../../lib/login')
98
describe('login', () => {
109
describe('#do', () => {
1110
const apiUrl = 'https://localhost:3100'
12-
const parsedApiUrl = new url.URL(apiUrl)
11+
const parsedApiUrl = new URL(apiUrl)
1312
const ethAddress = '0x74B904af705Eb2D5a6CDc174c08147bED478a60d'
1413
const password = 'password'
1514
const auth = { ethAddress, password }
@@ -31,7 +30,7 @@ describe('login', () => {
3130
.post(loginPath, auth)
3231
.reply(200, jsonTokens)
3332

34-
const parsedApiUrlHttp = new url.URL('http://localhost:3100')
33+
const parsedApiUrlHttp = new URL('http://localhost:3100')
3534
await login.do(ethAddress, password, parsedApiUrlHttp)
3635
.should.eventually.deep.equal(jsonTokens)
3736
})

test/lib/refresh.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const nock = require('nock')
2-
const url = require('url')
32
require('chai')
43
.use(require('chai-as-promised'))
54
.should()
@@ -9,7 +8,7 @@ const refresh = require('../../lib/refresh')
98
describe('refresh', () => {
109
describe('#do', () => {
1110
const apiUrl = 'https://localhost:3100'
12-
const parsedApiUrl = new url.URL(apiUrl)
11+
const parsedApiUrl = new URL(apiUrl)
1312
const refreshPath = '/v1/auth/refresh'
1413
const expiredRefreshToken = 'expiredRefresh'
1514
const expiredAccessToken = 'expiredAccess'

test/lib/requester.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const nock = require('nock')
2-
const url = require('url')
32
require('chai')
43
.use(require('chai-as-promised'))
54
.should()
@@ -8,9 +7,9 @@ const requester = require('../../lib/requester')
87

98
describe('requester', () => {
109
describe('#do', () => {
11-
const defaultApiUrl = new url.URL('https://api.mythx.io')
12-
const httpApiUrl = new url.URL('http://localhost:3100')
13-
const httpsApiUrl = new url.URL('https://localhost:3100')
10+
const defaultApiUrl = new URL('https://api.mythx.io')
11+
const httpApiUrl = new URL('http://localhost:3100')
12+
const httpsApiUrl = new URL('https://localhost:3100')
1413

1514
const validApiKey = 'valid-api-key'
1615
const uuid = 'my-uuid'
@@ -72,7 +71,7 @@ describe('requester', () => {
7271
})
7372

7473
it('should reject on api server connection failure', async () => {
75-
const invalidApiHostname = new url.URL('http://not-a-valid-hostname')
74+
const invalidApiHostname = new URL('http://not-a-valid-hostname')
7675

7776
await requester.do(data, validApiKey, invalidApiHostname).should.be.rejectedWith(Error)
7877
})

0 commit comments

Comments
 (0)