Skip to content

Commit

Permalink
[TASK] Canonicalize file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Apr 23, 2024
1 parent 1cc425d commit 3469ef7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Sitemap/UriValidationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

use EliasHaeussler\CacheWarmup\Exception;
use Psr\Http\Message;
use Symfony\Component\Filesystem;

use function str_starts_with;

/**
* UriValidationTrait.
Expand All @@ -48,6 +51,10 @@ protected function validateUri(): void
throw new Exception\UrlIsEmpty();
}

if (str_starts_with($url, 'file://')) {
$url = Filesystem\Path::canonicalize($url);
}

if (false === filter_var($url, FILTER_VALIDATE_URL)) {
throw new Exception\UrlIsInvalid($url);
}
Expand Down

0 comments on commit 3469ef7

Please sign in to comment.