Remove white-spaces, tabs and new-lines from screenshot urls before fetching in sync (#3)

* Remove white-spaces, tabs and new-lines from screenshot urls before fetching in sync

* Use trim instead of preg_replace to remove leading and trailing white spaces, tabs and new lines in screenshot urls

* Use trimmed url only to get data (not for base64 cache id)
This commit is contained in:
Aysel Afsar 2018-04-04 03:30:16 -04:00 коммит произвёл Roeland Jago Douma
Родитель d3cf4ad6a0
Коммит f0b77f0daa
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -46,8 +46,9 @@ foreach($supportedVersions as $version) {
foreach($app['screenshots'] as $screenshot) {
$url = $screenshot['url'];
if(!file_exists(__DIR__ . '/cache/' . base64_encode($url))) {
if (substr($url, 0, 8) === 'https://') {
$data = file_get_contents($url);
$trimmedUrl = trim($url);
if (substr($trimmedUrl, 0, 8) === 'https://') {
$data = file_get_contents($trimmedUrl);
file_put_contents(__DIR__ . '/cache/' . base64_encode($url), $data);
echo(
sprintf(