Skip to content

Commit 1f74b98

Browse files
refactor: extractUrl + add JS docs
Co-authored-by: Jordan Porter <insomniacrampage@hotmail.com>
1 parent 2d2ed29 commit 1f74b98

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/common/url/extract-url.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import { globalScope } from '../constants/runtime'
66
import { gosNREUMOriginals } from '../window/nreum'
77

8-
export function extractUrl (target) {
9-
if (typeof target === 'string') {
10-
return target
11-
} else if (typeof target === 'object' && target instanceof gosNREUMOriginals().o.REQ) {
12-
return target.url
13-
} else if (globalScope?.URL && typeof target === 'object' && target instanceof URL) {
14-
return target.href
15-
}
16-
return undefined
8+
/**
9+
* Extracts a URL from various target types.
10+
* @param {string|Request|URL} target - The target to extract the URL from. It can be a string, a Fetch Request object, or a URL object.
11+
* @returns {string|undefined} The extracted URL as a string, or undefined if the target type is not supported.
12+
*/
13+
export function extractUrl(target) {
14+
if (typeof target === 'string') return target
15+
else if (target instanceof gosNREUMOriginals().o.REQ) return target.url
16+
else if (globalScope?.URL && target instanceof URL) return target.href
1717
}

0 commit comments

Comments
 (0)