forked from open-telemetry/opentelemetry-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(instrumentation-http): fix eslint warnings
``` /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts 86:27 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts 86:27 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts 81:25 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api 156:43 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api 161:43 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api 213:35 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts 300:9 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts 274:9 warning 'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead node/no-deprecated-api ``` Generally speaking, `new URL()` is not a direct replacement for the deprecated `url.parse()`, so this type of change requires careful considerations. However, in this instance, these are all found in test code, which cuts out a lot of the typically associated issues, and the tests passing after the change is a good indication for correctness. Ref open-telemetry#5365
- Loading branch information
1 parent
83ad899
commit e606a4c
Showing
5 changed files
with
40 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,8 @@ describe('Utility', () => { | |
describe('getRequestInfo()', () => { | ||
it('should get options object', () => { | ||
const webUrl = 'http://u:[email protected]/aPath?qu=ry'; | ||
// This is explicitly testing interop with the legacy API | ||
// eslint-disable-next-line node/no-deprecated-api | ||
const urlParsed = url.parse(webUrl); | ||
const urlParsedWithoutPathname = { | ||
...urlParsed, | ||
|
@@ -152,13 +154,15 @@ describe('Utility', () => { | |
|
||
describe('getAbsoluteUrl()', () => { | ||
it('should return absolute url with localhost', () => { | ||
const path = '/test/1'; | ||
const result = utils.getAbsoluteUrl(url.parse(path), {}); | ||
assert.strictEqual(result, `http://localhost${path}`); | ||
const result = utils.getAbsoluteUrl({ path: '/test/1' }, {}); | ||
assert.strictEqual(result, 'http://localhost/test/1'); | ||
}); | ||
it('should return absolute url', () => { | ||
const absUrl = 'http://www.google/test/1?query=1'; | ||
const result = utils.getAbsoluteUrl(url.parse(absUrl), {}); | ||
const absUrl = 'http://www.google.com/test/1?query=1'; | ||
const result = utils.getAbsoluteUrl( | ||
{ protocol: 'http:', host: 'www.google.com', path: '/test/1?query=1' }, | ||
{} | ||
); | ||
assert.strictEqual(result, absUrl); | ||
}); | ||
it('should return default url', () => { | ||
|
@@ -210,7 +214,7 @@ describe('Utility', () => { | |
assert.strictEqual(utils.isValidOptionsType(options), false); | ||
}); | ||
}); | ||
for (const options of ['url', url.parse('http://url.com'), {}]) { | ||
for (const options of ['url', new URL('http://url.com'), {}]) { | ||
it(`should return true with the following value: ${JSON.stringify( | ||
options | ||
)}`, () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters