You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by qi...@apache.org on 2025/02/07 09:18:14 UTC

(skywalking-client-js) branch master updated: fix: The caught fetch request does not work when it receives a URL (#153)

This is an automated email from the ASF dual-hosted git repository.

qiuxiafan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 200eb7a  fix: The caught fetch request does not work when it receives a URL (#153)
200eb7a is described below

commit 200eb7a09fb453fa561166d804e2bf1ca855c793
Author: oldMan <li...@gmail.com>
AuthorDate: Fri Feb 7 17:18:09 2025 +0800

    fix: The caught fetch request does not work when it receives a URL (#153)
---
 src/trace/interceptors/fetch.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/trace/interceptors/fetch.ts b/src/trace/interceptors/fetch.ts
index 9c8f8da..3710015 100644
--- a/src/trace/interceptors/fetch.ts
+++ b/src/trace/interceptors/fetch.ts
@@ -38,7 +38,9 @@ export default function windowFetch(options: CustomOptionsType, segments: Segmen
     } as SegmentFields;
     let url = {} as URL;
     // for args[0] is Request object see: https://developer.mozilla.org/zh-CN/docs/Web/API/fetch
-    if (Object.prototype.toString.call(args[0]) === '[object Request]') {
+    if (Object.prototype.toString.call(args[0]) === '[object URL]') {
+      url = args[0];
+    } else if (Object.prototype.toString.call(args[0]) === '[object Request]') {
       url = new URL(args[0].url);
     } else {
       if (args[0].startsWith('http://') || args[0].startsWith('https://')) {