@@ -48,38 +48,38 @@ function parseURL (url) {
48
48
url = new URL ( url )
49
49
50
50
if ( ! / ^ h t t p s ? : / . test ( url . origin || url . protocol ) ) {
51
- throw new InvalidArgumentError ( 'invalid protocol' )
51
+ throw new InvalidArgumentError ( 'Invalid URL protocol: the URL must start with `http:` or `https:`. ' )
52
52
}
53
53
54
54
return url
55
55
}
56
56
57
57
if ( ! url || typeof url !== 'object' ) {
58
- throw new InvalidArgumentError ( 'invalid url ' )
58
+ throw new InvalidArgumentError ( 'Invalid URL: The URL argument must be a non-null object. ' )
59
59
}
60
60
61
61
if ( url . port != null && url . port !== '' && ! Number . isFinite ( parseInt ( url . port ) ) ) {
62
- throw new InvalidArgumentError ( 'invalid port' )
62
+ throw new InvalidArgumentError ( 'Invalid URL: port must be a valid integer or a string representation of an integer. ' )
63
63
}
64
64
65
65
if ( url . path != null && typeof url . path !== 'string' ) {
66
- throw new InvalidArgumentError ( 'invalid path' )
66
+ throw new InvalidArgumentError ( 'Invalid URL path: the path must be a string or null/undefined. ' )
67
67
}
68
68
69
69
if ( url . pathname != null && typeof url . pathname !== 'string' ) {
70
- throw new InvalidArgumentError ( 'invalid pathname' )
70
+ throw new InvalidArgumentError ( 'Invalid URL pathname: the pathname must be a string or null/undefined. ' )
71
71
}
72
72
73
73
if ( url . hostname != null && typeof url . hostname !== 'string' ) {
74
- throw new InvalidArgumentError ( 'invalid hostname' )
74
+ throw new InvalidArgumentError ( 'Invalid URL hostname: the hostname must be a string or null/undefined. ' )
75
75
}
76
76
77
77
if ( url . origin != null && typeof url . origin !== 'string' ) {
78
- throw new InvalidArgumentError ( 'invalid origin' )
78
+ throw new InvalidArgumentError ( 'Invalid URL origin: the origin must be a string or null/undefined. ' )
79
79
}
80
80
81
81
if ( ! / ^ h t t p s ? : / . test ( url . origin || url . protocol ) ) {
82
- throw new InvalidArgumentError ( 'invalid protocol' )
82
+ throw new InvalidArgumentError ( 'Invalid URL protocol: the URL must start with `http:` or `https:`. ' )
83
83
}
84
84
85
85
if ( ! ( url instanceof URL ) ) {
0 commit comments