aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Nikolov <ggeorgi60@gmail.com>2025-02-01 17:55:57 +0200
committerGeorgi Nikolov <ggeorgi60@gmail.com>2025-02-01 17:55:57 +0200
commit34903b6553f6483f52e57133fc6305779461db29 (patch)
treed1e3ff9c44ee5252f4aeca5d8ecbfe0d37ed2d6a
parent02995bfe9827c0c329c9c397411d83bd6918d096 (diff)
downloadnowayforward_human-34903b6553f6483f52e57133fc6305779461db29.tar
nowayforward_human-34903b6553f6483f52e57133fc6305779461db29.tar.gz
nowayforward_human-34903b6553f6483f52e57133fc6305779461db29.zip
Fixed the correct resources not being downloaded
-rw-r--r--controllers/archive.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/controllers/archive.php b/controllers/archive.php
index ae25482..35ab1dd 100644
--- a/controllers/archive.php
+++ b/controllers/archive.php
@@ -176,11 +176,19 @@ class DownloadPage {
// Otherwise resolve it agains the base url
// Get only the domain with the protocol
$pattern = '/((^.*\/\/|.{0,0})[a-z0-9A-Z\.]+)(\/\w+|$)/';
- $actualUrl = $baseUrl;
+ $rootUrl = $baseUrl;
if (preg_match($pattern, $baseUrl, $matches)) {
- $actualUrl = $matches[1];
+ $rootUrl = $matches[1];
}
- return rtrim($actualUrl, '/') . '/' . ltrim($relativeUrl, '/');
+ // Get the url that includes the data relatively from the root
+ $result = rtrim($baseUrl, '/') . '/' . ltrim($relativeUrl, '/');
+ if ($this->isResourceAccessible($result)) {
+ return $result;
+ }
+ // If the resource does not exist there
+ // return a URL from the page url
+ $result = rtrim($rootUrl, '/') . '/' . ltrim($relativeUrl, '/');
+ return $result;
}
function handleCssUrls(&$content) : void {
@@ -330,7 +338,7 @@ class DownloadPage {
if (count($correct_results) != 0) {
// If there are any links that are the same as the urls make the $dom attribute point
// to the latest version of that page
- $tag->setAttribute($attribute, "/archives/" . $correct_results[0]->WID . "/index.html");
+ $tag->setAttribute($attribute, "/archives/" . $correct_results[0]->WID . "/index.php");
} else {
// If there are no pages that are like that url point to the landing page of the site
// that says that this page was not yet archived