pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/REBELinBLUE/deployer/commit/8a405e01286d3cf25ff4f1849be3e0cba3538fbf

.css" /> Adding feature "match string when checking URLs" (#385) · REBELinBLUE/deployer@8a405e0 · GitHub
Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit 8a405e0

Browse files
axelozREBELinBLUE
authored andcommitted
Adding feature "match string when checking URLs" (#385)
1 parent f793de2 commit 8a405e0

File tree

14 files changed

+134323
-24
lines changed

14 files changed

+134323
-24
lines changed

app/CheckUrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CheckUrl extends Model
2222
*
2323
* @var array
2424
*/
25-
protected $fillable = ['name', 'url', 'project_id', 'period'];
25+
protected $fillable = ['name', 'url', 'project_id', 'period', 'match'];
2626

2727
/**
2828
* The attributes excluded from the model's JSON form.

app/Http/Controllers/Resources/CheckUrlController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public function store(StoreCheckUrlRequest $request, ResponseFactory $response)
3939
'name',
4040
'url',
4141
'period',
42-
'project_id'
42+
'project_id',
43+
'match'
4344
)), Response::HTTP_CREATED);
4445
}
4546

@@ -56,7 +57,8 @@ public function update($url_id, StoreCheckUrlRequest $request)
5657
return $this->repository->updateById($request->only(
5758
'name',
5859
'url',
59-
'period'
60+
'period',
61+
'match'
6062
), $url_id);
6163
}
6264
}

app/Jobs/RequestProjectCheckUrl.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Queue\SerializesModels;
1010
use Illuminate\Support\Collection;
1111
use REBELinBLUE\Deployer\CheckUrl;
12+
use REBELinBLUE\Deployer\Exceptions\CheckUrlMatchException;
1213

1314
/**
1415
* Request the urls.
@@ -48,13 +49,24 @@ public function handle(Client $client)
4849
$link->last_log = null;
4950

5051
try {
51-
$client->get($link->url);
52+
$request = $client->get($link->url);
53+
54+
if (!empty($link->match) && !is_null($link->match)) {
55+
$body = (string)$request->getBody();
56+
if (! preg_match('~'.htmlentities(trim(preg_quote($link->match, '~'))).'~i', $body)) {
57+
throw new CheckUrlMatchException('The URL is live but we could not find the "'.$link->match.'" content into it');
58+
}
59+
}
5260

5361
$link->online();
5462
} catch (RequestException $error) {
5563
$link->offline();
5664

5765
$link->last_log = $this->generateLog($error);
66+
} catch (CheckUrlMatchException $error) {
67+
$link->offline();
68+
69+
$link->last_log = $error->getMessage();
5870
}
5971

6072
$link->save();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateUrlMatchColumn extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
//
17+
Schema::table('check_urls', function (Blueprint $table) {
18+
$table->string('match')->after('period')->nullable();
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
//
30+
Schema::table('check_urls', function (Blueprint $table) {
31+
$table->dropColumn('match');
32+
});
33+
}
34+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy