Skip to content

Commit 1f587bc

Browse files
committed
refactor: ♻️ update query parameter parsing
1 parent 96cb9ba commit 1f587bc

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

packages/node/test/notifier.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ describe('node notifier', () => {
44
beforeAll(() => {
55
jest.spyOn(console, 'debug').mockImplementation(() => {})
66
jest.spyOn(console, 'warn').mockImplementation(() => {})
7+
jest.spyOn(console, 'log').mockImplementation(() => {})
78
})
89

910
beforeEach(() => {

packages/plugin-aws-lambda/test/serverless-express.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ let sentEvents
1414
let sentSessions
1515

1616
describe('serverless express', function () {
17+
beforeAll(() => {
18+
jest.spyOn(console, 'debug').mockImplementation(() => {})
19+
})
20+
1721
beforeEach(function () {
1822
sentEvents = []
1923
sentSessions = []

packages/plugin-network-instrumentation/lib/redact-query-parameters.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function (url, redactedKeys) {
1616

1717
// Parse the URL - use a base only for relative URLs
1818
const urlObj = new URL(url, base)
19-
const params = new URLSearchParams(urlObj.search)
19+
const params = urlObj.search ? new URLSearchParams(urlObj.search) : new URLSearchParams()
2020

2121
// Convert URLSearchParams to object without using Object.fromEntries()
2222
const paramsObject = {}
@@ -25,14 +25,16 @@ module.exports = function (url, redactedKeys) {
2525
})
2626

2727
const redactedParams = redactValues(paramsObject, redactedKeys)
28-
urlObj.search = new URLSearchParams(redactedParams).toString()
28+
if (urlObj.search) {
29+
urlObj.search = new URLSearchParams(redactedParams).toString()
30+
}
2931

3032
// Return appropriate format based on original URL type
3133
if (isAbsolute) {
3234
return decodeURI(urlObj.toString())
3335
}
3436

3537
// For relative URLs, return only the path + search + hash components
36-
const relativePart = urlObj.pathname + urlObj.search + urlObj.hash
38+
const relativePart = urlObj.pathname + (urlObj.search || '') + urlObj.hash
3739
return decodeURI(relativePart)
3840
}

test/browser/features/http_errors.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Feature: HTTP Errors
1616
And the exception "errorClass" equals "HTTPError"
1717
And the error payload field "events.0.exceptions.0.message" equals the stored value "expected.exception.message"
1818
And the event "severity" equals "error"
19-
And the event "unhandled" is true
19+
And the event "unhandled" is false
2020
And the event "severityReason.type" equals "httpError"
2121
And the error payload field "events.0.context" equals the stored value "expected.context"
2222

@@ -46,7 +46,7 @@ Feature: HTTP Errors
4646
And the exception "errorClass" equals "HTTPError"
4747
And the error payload field "events.0.exceptions.0.message" equals the stored value "expected.exception.message"
4848
And the event "severity" equals "error"
49-
And the event "unhandled" is true
49+
And the event "unhandled" is false
5050
And the event "severityReason.type" equals "httpError"
5151
And the error payload field "events.0.context" equals the stored value "expected.context"
5252

@@ -78,7 +78,7 @@ Feature: HTTP Errors
7878
And the exception "errorClass" equals "HTTPError"
7979
And the error payload field "events.0.exceptions.0.message" equals the stored value "expected.exception.message"
8080
And the event "severity" equals "error"
81-
And the event "unhandled" is true
81+
And the event "unhandled" is false
8282
And the event "severityReason.type" equals "httpError"
8383
And the error payload field "events.0.context" equals the stored value "expected.context"
8484

@@ -109,7 +109,7 @@ Feature: HTTP Errors
109109
And the exception "errorClass" equals "HTTPError"
110110
And the error payload field "events.0.exceptions.0.message" equals the stored value "expected.exception.message"
111111
And the event "severity" equals "error"
112-
And the event "unhandled" is true
112+
And the event "unhandled" is false
113113
And the event "severityReason.type" equals "httpError"
114114
And the error payload field "events.0.context" equals the stored value "expected.context"
115115

0 commit comments

Comments
 (0)