Работает обработка ссылок на таблицы с численностью

This commit is contained in:
2024-09-06 14:11:38 +03:00
parent 04374fef40
commit 2be45826c1
1698 changed files with 138656 additions and 174 deletions

View File

@@ -1,16 +1,15 @@
<?php
namespace ContingentParser\Http;
class UrlBuilder
final class UrlBuilder
{
public function __construct() {}
/**
* Строит валидный URL сайта
* @param string $url
* Изначальный URL
* @param string $url Изначальный URL
* @return string
*/
public function build(string $url) : string
public function build(string $url): string
{
// Строит -> https://<base_uri>
$url = trim(strtolower($url));
@@ -18,13 +17,26 @@ class UrlBuilder
$url = str_replace("www/", "www.", $url);
$url = str_replace("http:\\\\", "", $url);
if (!preg_match('#^https?://#', $url)) {
$url = "http://$url";
$url = "https://$url";
}
// $url = str_replace("http://", "https://", $url);
$url = str_replace("http://", "https://", $url);
$arr = parse_url($url);
$url = $arr['scheme'] . '://' . $arr['host'] . '/';
// $url = str_replace("www.", "", $url);
$url = str_replace("www.", "", $url);
$url = str_replace("_", "/", $url);
return trim($url);
}
public function checkUri(string $uri): bool
{
if (str_ends_with($uri, ".pdf")
|| str_ends_with($uri, ".docx")
|| str_ends_with($uri, ".doc")
|| str_starts_with($uri, "javascript")
) {
return false;
}
return true;
}
}