aboutsummaryrefslogtreecommitdiff
path: root/controllers/archive.php
diff options
context:
space:
mode:
authorGeorgi Nikolov <ggeorgi60@gmail.com>2025-01-26 14:59:16 +0200
committerGeorgi Nikolov <ggeorgi60@gmail.com>2025-01-26 14:59:16 +0200
commit5ee3df4d830ead2f19d0150619a06ce5ac841b7b (patch)
treef1696382828697205885d06da4bcfa371cd0c05e /controllers/archive.php
parentaabefb55e84c9975d2c5ab72f2c73e5a4e5d128b (diff)
downloadnowayforward_human-5ee3df4d830ead2f19d0150619a06ce5ac841b7b.tar
nowayforward_human-5ee3df4d830ead2f19d0150619a06ce5ac841b7b.tar.gz
nowayforward_human-5ee3df4d830ead2f19d0150619a06ce5ac841b7b.zip
Fixed the inside pages' resources not being downloaded
Diffstat (limited to 'controllers/archive.php')
-rw-r--r--controllers/archive.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/controllers/archive.php b/controllers/archive.php
index a8d8598..e730719 100644
--- a/controllers/archive.php
+++ b/controllers/archive.php
@@ -73,7 +73,7 @@ class DownloadPage {
function getCorrectLinkPattern($page_url) : string {
// NOTE: Offset by 2 because of the '//' of the protocol
- $page_url = substr($page_url, strpos($page_url, "//") + 2, strlen($page_url));
+ $page_url = substr($page_url, strpos($page_url, "//"), strlen($page_url));
return $page_url;
}
@@ -139,7 +139,13 @@ class DownloadPage {
return $relativeUrl;
}
// Otherwise resolve it agains the base url
- return rtrim($baseUrl, '/') . '/' . ltrim($relativeUrl, '/');
+ // Get only the domain with the protocol
+ $pattern = '/((^.*\/\/|.{0,0})[a-z0-9A-Z\.]+)(\/\w+|$)/';
+ $actualUrl = $baseUrl;
+ if (preg_match($pattern, $baseUrl, $matches)) {
+ $actualUrl = $matches[1];
+ }
+ return rtrim($actualUrl, '/') . '/' . ltrim($relativeUrl, '/');
}
function handleCssUrls(&$content) : void {