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 a58ad50  fix: wrong URL when using relative path (#46)
a58ad50 is described below

commit a58ad50e2957a03a59097e3d1610029d2e7d4db7
Author: keke <yongket...@gmail.com>
AuthorDate: Fri Mar 5 15:20:42 2021 +0800

    fix: wrong URL when using relative path (#46)
    
    * fix `//examile.com` url error
    
    * use window.location.protocol
---
 src/trace/segment.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/trace/segment.ts b/src/trace/segment.ts
index 28bf33f..6e8f650 100644
--- a/src/trace/segment.ts
+++ b/src/trace/segment.ts
@@ -40,8 +40,10 @@ export default function traceSegment(options: 
CustomOptionsType) {
     const xhrState = event.detail.readyState;
     const config = event.detail.getRequestConfig;
     let url = {} as URL;
-    if (config[1].startsWith('http://') || config[1].startsWith('https://') || 
config[1].startsWith('//')) {
+    if (config[1].startsWith('http://') || config[1].startsWith('https://')) {
       url = new URL(config[1]);
+    } else if (config[1].startsWith('//')) {
+      url = new URL(`${window.location.protocol}${config[1]}`);
     } else {
       url = new URL(window.location.href);
       url.pathname = config[1];

Reply via email to