Skip to content

Commit

Permalink
optionally remove favicon from proxy output
Browse files Browse the repository at this point in the history
  • Loading branch information
Athlon1600 committed Jun 18, 2020
1 parent fed8643 commit 074463c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/UrlFormPlugin.php
@@ -1,5 +1,6 @@
<?php

use Proxy\Config;
use Proxy\Event\ProxyEvent;
use Proxy\Plugin\AbstractPlugin;

Expand All @@ -25,6 +26,14 @@ public function onCompleted(ProxyEvent $event)

$output = $response->getContent();

// remove favicon if so
if (Config::get('replace_icon')) {

$output = preg_replace_callback('/<link[^>]+rel=".*?(?:shortcut|icon).*?"[^>]+>/', function ($matches) {
return "";
}, $output);
}

// does the html page contain <body> tag, if so insert our form right after <body> tag starts
$output = preg_replace('@<body.*?>@is', '$0' . PHP_EOL . $url_form, $output, 1, $count);

Expand Down

0 comments on commit 074463c

Please sign in to comment.