From ce112208d4b88b043c2ba4cf07551ea2ced7a144 Mon Sep 17 00:00:00 2001
From: nilaoda <nilaoda@live.com>
Date: Sun, 18 Sep 2022 19:45:56 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96location=E8=AF=BB=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs b/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs
index 203e957..46ee563 100644
--- a/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs
+++ b/src/N_m3u8DL-RE.Common/Util/HTTPUtil.cs
@@ -55,10 +55,24 @@ namespace N_m3u8DL_RE.Common.Util
             {
                 HttpResponseHeaders respHeaders = webResponse.Headers;
                 Logger.Debug(respHeaders.ToString());
-                if (respHeaders != null && respHeaders.Location != null && respHeaders.Location.AbsoluteUri != url)
+                if (respHeaders != null && respHeaders.Location != null)
                 {
-                    var redirectedUrl = respHeaders.Location.AbsoluteUri;
-                    return await DoGetAsync(redirectedUrl, headers);
+                    var redirectedUrl = "";
+                    if (!respHeaders.Location.IsAbsoluteUri)
+                    {
+                        Uri uri1 = new Uri(url);
+                        Uri uri2 = new Uri(uri1, respHeaders.Location);
+                        redirectedUrl = uri2.ToString();
+                    }
+                    else
+                    {
+                        redirectedUrl = respHeaders.Location.AbsoluteUri;
+                    }
+                    
+                    if (redirectedUrl != url)
+                    {
+                        return await DoGetAsync(redirectedUrl, headers);
+                    }
                 }
             }
             //手动将跳转后的URL设置进去, 用于后续取用