Skip to content

Commit 2a197de

Browse files
committed
fix: use url.host over url.hostname to include port numbers
1 parent 85e980b commit 2a197de

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

packages/plugin-http-errors/http-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = (config = {}) => {
100100
const extractDomain = (url) => {
101101
try {
102102
const urlObj = new URL(url)
103-
return urlObj.hostname
103+
return urlObj.host
104104
} catch (e) {
105105
return 'unknown'
106106
}

packages/plugin-http-errors/test/http-errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ describe('plugin-http-errors', () => {
648648

649649
expect(notifyCallbacks.length).toBe(1)
650650
const event = notifyCallbacks[0]
651-
expect(event.context).toBe('GET example.com')
651+
expect(event.context).toBe('GET example.com:8080')
652652
expect(event.errors[0].errorMessage).toBe('404: https://example.com:8080/api/users')
653653
})
654654

test/browser/features/http_errors.feature

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,32 @@ Feature: HTTP Errors
2929
And the event "response.headers.content-length" equals "37"
3030
# response.body is not reported for fetch requests
3131
# response.bodyLength is not reported for fetch requests
32+
33+
@skip
34+
Scenario: XML HTTP Request
35+
When I navigate to the test URL "/http_errors/xhr/index.html"
36+
And I wait to receive an error
37+
Then the error is a valid browser payload for the error reporting API
38+
39+
And I define "expected.context" as "GET <browser.hostname>"
40+
And I define "expected.exception.message" as "404: <browser.url>/reflect?status=404"
41+
And I define "expected.request.url" as "<browser.url>/reflect?status=404"
42+
43+
And the exception "errorClass" equals "HTTPError"
44+
And the error payload field "events.0.exceptions.0.message" equals the stored value "expected.exception.message"
45+
And the event "severity" equals "error"
46+
And the event "unhandled" is true
47+
And the event "severityReason.type" equals "httpError"
48+
And the error payload field "events.0.context" equals the stored value "expected.context"
49+
50+
And the error payload field "events.0.request.url" equals the stored value "expected.request.url"
51+
And the event "request.httpMethod" equals "GET"
52+
And the event "request.params.status" equals "404"
53+
And the event "request.body" equals ""
54+
And the event "request.bodyLength" equals 0
55+
56+
And the event "response.statusCode" equals 404
57+
And the event "response.headers.content-length" equals "37"
58+
And the event "response.body" equals ""
59+
And the event "response.bodyLength" equals 37
60+

0 commit comments

Comments
 (0)