Completed
Push — master ( f73514...b3b2b5 )
by Lars
17s queued 13s
created
src/voku/helper/HtmlMin.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     }
463 463
 	
464 464
     /**
465
-     * @param bool $setLocalDomain
465
+     * @param bool $localDomain
466 466
      *
467 467
      * @return $this
468 468
      */
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
     /**
1339 1339
      * @param \DOMNode $node
1340 1340
      *
1341
-     * @return \DOMNode|null
1341
+     * @return null|\DOMElement
1342 1342
      */
1343 1343
     protected function getNextSiblingOfTypeDOMElement(\DOMNode $node)
1344 1344
     {
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         $this->doRemoveHttpsPrefixFromAttributes = $doRemoveHttpsPrefixFromAttributes;
436 436
 
437 437
         return $this;
438
-	}
438
+  }
439 439
 	
440 440
     /**
441 441
      * @param bool $keepPrefixOnExternalAttributes
@@ -468,24 +468,24 @@  discard block
 block discarded – undo
468 468
      */
469 469
     public function setLocalDomain(string $localDomain = ''): self
470 470
     {
471
-		if ($localDomain === ''){
472
-			$this->localDomain = $_SERVER['SERVER_NAME'];
473
-		}else{
474
-			$this->localDomain = rtrim(preg_replace('/(https?:)?\/\//', '', $localDomain), '/');
475
-		}
471
+    if ($localDomain === ''){
472
+      $this->localDomain = $_SERVER['SERVER_NAME'];
473
+    }else{
474
+      $this->localDomain = rtrim(preg_replace('/(https?:)?\/\//', '', $localDomain), '/');
475
+    }
476 476
 
477 477
         return $this;
478
-	}
478
+  }
479 479
 	
480
-	/**
481
-     * @param void
482
-     *
483
-     * @return $this->localDomain
484
-     */
485
-	public function getLocalDomain(): string
486
-	{
487
-		return $this->localDomain;
488
-	}
480
+  /**
481
+   * @param void
482
+   *
483
+   * @return $this->localDomain
484
+   */
485
+  public function getLocalDomain(): string
486
+  {
487
+    return $this->localDomain;
488
+  }
489 489
 
490 490
     /**
491 491
      * @param bool $doRemoveOmittedHtmlTags
@@ -704,206 +704,206 @@  discard block
 block discarded – undo
704 704
         return \in_array($tag_name, self::$optional_end_tags, true)
705 705
                ||
706 706
                (
707
-                   $tag_name === 'li'
707
+                    $tag_name === 'li'
708 708
                    &&
709 709
                    (
710
-                       $nextSibling === null
710
+                        $nextSibling === null
711 711
                        ||
712 712
                        (
713
-                           $nextSibling instanceof \DOMElement
713
+                            $nextSibling instanceof \DOMElement
714 714
                            &&
715 715
                            $nextSibling->tagName === 'li'
716
-                       )
717
-                   )
718
-               )
716
+                        )
717
+                    )
718
+                )
719 719
                ||
720 720
                (
721
-                   $tag_name === 'rp'
721
+                    $tag_name === 'rp'
722 722
                    &&
723 723
                    (
724
-                       $nextSibling === null
724
+                        $nextSibling === null
725 725
                        ||
726 726
                        (
727
-                           $nextSibling instanceof \DOMElement
727
+                            $nextSibling instanceof \DOMElement
728 728
                            &&
729 729
                            (
730
-                               $nextSibling->tagName === 'rp'
730
+                                $nextSibling->tagName === 'rp'
731 731
                                ||
732 732
                                $nextSibling->tagName === 'rt'
733
-                           )
734
-                       )
735
-                   )
736
-               )
733
+                            )
734
+                        )
735
+                    )
736
+                )
737 737
                ||
738 738
                (
739
-                   $tag_name === 'tr'
739
+                    $tag_name === 'tr'
740 740
                    &&
741 741
                    (
742
-                       $nextSibling === null
742
+                        $nextSibling === null
743 743
                        ||
744 744
                        (
745
-                           $nextSibling instanceof \DOMElement
745
+                            $nextSibling instanceof \DOMElement
746 746
                            &&
747 747
                            $nextSibling->tagName === 'tr'
748
-                       )
749
-                   )
750
-               )
748
+                        )
749
+                    )
750
+                )
751 751
                ||
752 752
                (
753
-                   $tag_name === 'source'
753
+                    $tag_name === 'source'
754 754
                    &&
755 755
                    (
756
-                       $parent_tag_name === 'audio'
756
+                        $parent_tag_name === 'audio'
757 757
                        ||
758 758
                        $parent_tag_name === 'video'
759 759
                        ||
760 760
                        $parent_tag_name === 'picture'
761 761
                        ||
762 762
                        $parent_tag_name === 'source'
763
-                   )
763
+                    )
764 764
                    &&
765 765
                    (
766
-                       $nextSibling === null
766
+                        $nextSibling === null
767 767
                        ||
768 768
                        (
769
-                           $nextSibling instanceof \DOMElement
769
+                            $nextSibling instanceof \DOMElement
770 770
                            &&
771 771
                            $nextSibling->tagName === 'source'
772
-                       )
773
-                   )
774
-               )
772
+                        )
773
+                    )
774
+                )
775 775
                ||
776 776
                (
777
-                   (
778
-                       $tag_name === 'td'
777
+                    (
778
+                        $tag_name === 'td'
779 779
                        ||
780 780
                        $tag_name === 'th'
781
-                   )
781
+                    )
782 782
                    &&
783 783
                    (
784
-                       $nextSibling === null
784
+                        $nextSibling === null
785 785
                        ||
786 786
                        (
787
-                           $nextSibling instanceof \DOMElement
787
+                            $nextSibling instanceof \DOMElement
788 788
                            &&
789 789
                            (
790
-                               $nextSibling->tagName === 'td'
790
+                                $nextSibling->tagName === 'td'
791 791
                                ||
792 792
                                $nextSibling->tagName === 'th'
793
-                           )
794
-                       )
795
-                   )
796
-               )
793
+                            )
794
+                        )
795
+                    )
796
+                )
797 797
                ||
798 798
                (
799
-                   (
800
-                       $tag_name === 'dd'
799
+                    (
800
+                        $tag_name === 'dd'
801 801
                        ||
802 802
                        $tag_name === 'dt'
803
-                   )
803
+                    )
804 804
                    &&
805 805
                    (
806
-                       (
807
-                           $nextSibling === null
806
+                        (
807
+                            $nextSibling === null
808 808
                            &&
809 809
                            $tag_name === 'dd'
810
-                       )
810
+                        )
811 811
                        ||
812 812
                        (
813
-                           $nextSibling instanceof \DOMElement
813
+                            $nextSibling instanceof \DOMElement
814 814
                            &&
815 815
                            (
816
-                               $nextSibling->tagName === 'dd'
816
+                                $nextSibling->tagName === 'dd'
817 817
                                ||
818 818
                                $nextSibling->tagName === 'dt'
819
-                           )
820
-                       )
821
-                   )
822
-               )
819
+                            )
820
+                        )
821
+                    )
822
+                )
823 823
                ||
824 824
                (
825
-                   $tag_name === 'option'
825
+                    $tag_name === 'option'
826 826
                    &&
827 827
                    (
828
-                       $nextSibling === null
828
+                        $nextSibling === null
829 829
                        ||
830 830
                        (
831
-                           $nextSibling instanceof \DOMElement
831
+                            $nextSibling instanceof \DOMElement
832 832
                            &&
833 833
                            (
834
-                               $nextSibling->tagName === 'option'
834
+                                $nextSibling->tagName === 'option'
835 835
                                ||
836 836
                                $nextSibling->tagName === 'optgroup'
837
-                           )
838
-                       )
839
-                   )
840
-               )
837
+                            )
838
+                        )
839
+                    )
840
+                )
841 841
                ||
842 842
                (
843
-                   $tag_name === 'p'
843
+                    $tag_name === 'p'
844 844
                    &&
845 845
                    (
846
-                       (
847
-                           $nextSibling === null
846
+                        (
847
+                            $nextSibling === null
848 848
                            &&
849 849
                            (
850
-                               $node->parentNode !== null
850
+                                $node->parentNode !== null
851 851
                                &&
852 852
                                !\in_array(
853
-                                   $node->parentNode->nodeName,
854
-                                   [
855
-                                       'a',
856
-                                       'audio',
857
-                                       'del',
858
-                                       'ins',
859
-                                       'map',
860
-                                       'noscript',
861
-                                       'video',
862
-                                   ],
863
-                                   true
864
-                               )
865
-                           )
866
-                       )
853
+                                    $node->parentNode->nodeName,
854
+                                    [
855
+                                        'a',
856
+                                        'audio',
857
+                                        'del',
858
+                                        'ins',
859
+                                        'map',
860
+                                        'noscript',
861
+                                        'video',
862
+                                    ],
863
+                                    true
864
+                                )
865
+                            )
866
+                        )
867 867
                        ||
868 868
                        (
869
-                           $nextSibling instanceof \DOMElement
869
+                            $nextSibling instanceof \DOMElement
870 870
                            &&
871 871
                            \in_array(
872
-                               $nextSibling->tagName,
873
-                               [
874
-                                   'address',
875
-                                   'article',
876
-                                   'aside',
877
-                                   'blockquote',
878
-                                   'dir',
879
-                                   'div',
880
-                                   'dl',
881
-                                   'fieldset',
882
-                                   'footer',
883
-                                   'form',
884
-                                   'h1',
885
-                                   'h2',
886
-                                   'h3',
887
-                                   'h4',
888
-                                   'h5',
889
-                                   'h6',
890
-                                   'header',
891
-                                   'hgroup',
892
-                                   'hr',
893
-                                   'menu',
894
-                                   'nav',
895
-                                   'ol',
896
-                                   'p',
897
-                                   'pre',
898
-                                   'section',
899
-                                   'table',
900
-                                   'ul',
901
-                               ],
902
-                               true
903
-                           )
904
-                       )
905
-                   )
906
-               );
872
+                                $nextSibling->tagName,
873
+                                [
874
+                                    'address',
875
+                                    'article',
876
+                                    'aside',
877
+                                    'blockquote',
878
+                                    'dir',
879
+                                    'div',
880
+                                    'dl',
881
+                                    'fieldset',
882
+                                    'footer',
883
+                                    'form',
884
+                                    'h1',
885
+                                    'h2',
886
+                                    'h3',
887
+                                    'h4',
888
+                                    'h5',
889
+                                    'h6',
890
+                                    'header',
891
+                                    'hgroup',
892
+                                    'hr',
893
+                                    'menu',
894
+                                    'nav',
895
+                                    'ol',
896
+                                    'p',
897
+                                    'pre',
898
+                                    'section',
899
+                                    'table',
900
+                                    'ul',
901
+                                ],
902
+                                true
903
+                            )
904
+                        )
905
+                    )
906
+                );
907 907
     }
908 908
 
909 909
     protected function domNodeToString(\DOMNode $node): string
@@ -935,9 +935,9 @@  discard block
 block discarded – undo
935 935
                     }
936 936
 
937 937
                     $html .= '<!DOCTYPE ' . $child->name . ''
938
-                             . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
939
-                             . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
940
-                             . '>';
938
+                              . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
939
+                              . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
940
+                              . '>';
941 941
                 }
942 942
             } elseif ($child instanceof \DOMElement) {
943 943
                 $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child));
@@ -1129,14 +1129,14 @@  discard block
 block discarded – undo
1129 1129
     public function isDoMakeSameDomainLinksRelative(): bool
1130 1130
     {
1131 1131
         return $this->doMakeSameDomainLinksRelative;
1132
-	}
1132
+  }
1133 1133
 	
1134 1134
     /**
1135 1135
      * @param bool
1136 1136
      */
1137 1137
     public function isLocalDomainSet(): bool
1138 1138
     {
1139
-		return (!empty($this->localDomain));
1139
+    return (!empty($this->localDomain));
1140 1140
     }
1141 1141
 
1142 1142
     /**
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
      */
469 469
     public function setLocalDomain(string $localDomain = ''): self
470 470
     {
471
-		if ($localDomain === ''){
471
+		if ($localDomain === '') {
472 472
 			$this->localDomain = $_SERVER['SERVER_NAME'];
473
-		}else{
473
+		} else {
474 474
 			$this->localDomain = rtrim(preg_replace('/(https?:)?\/\//', '', $localDomain), '/');
475 475
 		}
476 476
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
                     $attr_val = $attribute->value;
638 638
                 }
639 639
 
640
-                $attr_str .= ($omit_quotes ? '' : $quoteTmp) . $attr_val . ($omit_quotes ? '' : $quoteTmp);
640
+                $attr_str .= ($omit_quotes ? '' : $quoteTmp).$attr_val.($omit_quotes ? '' : $quoteTmp);
641 641
                 $attr_str .= ' ';
642 642
             }
643 643
         }
@@ -934,21 +934,21 @@  discard block
 block discarded – undo
934 934
                         $tmpTypePublic = 'PUBLIC';
935 935
                     }
936 936
 
937
-                    $html .= '<!DOCTYPE ' . $child->name . ''
938
-                             . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '')
939
-                             . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '')
937
+                    $html .= '<!DOCTYPE '.$child->name.''
938
+                             . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '')
939
+                             . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '')
940 940
                              . '>';
941 941
                 }
942 942
             } elseif ($child instanceof \DOMElement) {
943
-                $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child));
944
-                $html .= '>' . $this->domNodeToString($child);
943
+                $html .= \rtrim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child));
944
+                $html .= '>'.$this->domNodeToString($child);
945 945
 
946 946
                 if (
947 947
                     !$this->doRemoveOmittedHtmlTags
948 948
                     ||
949 949
                     !$this->domNodeClosingTagOptional($child)
950 950
                 ) {
951
-                    $html .= '</' . $child->tagName . '>';
951
+                    $html .= '</'.$child->tagName.'>';
952 952
                 }
953 953
 
954 954
                 if (!$this->doRemoveWhitespaceAroundTags) {
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
                     $html .= $child->wholeText;
1013 1013
                 }
1014 1014
             } elseif ($child instanceof \DOMComment) {
1015
-                $html .= '<!--' . $child->textContent . '-->';
1015
+                $html .= '<!--'.$child->textContent.'-->';
1016 1016
             }
1017 1017
         }
1018 1018
 
@@ -1244,8 +1244,8 @@  discard block
 block discarded – undo
1244 1244
         if (\strpos($html, ' ') !== false) {
1245 1245
             $html = (string) \preg_replace_callback(
1246 1246
                 '#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#',
1247
-                static function ($matches) {
1248
-                    return '<' . $matches[1] . \preg_replace('#([^\s=]+)(=([\'"]?)(.*?)\3)?(\s+|$)#su', ' $1$2', $matches[2]) . $matches[3] . '>';
1247
+                static function($matches) {
1248
+                    return '<'.$matches[1].\preg_replace('#([^\s=]+)(=([\'"]?)(.*?)\3)?(\s+|$)#su', ' $1$2', $matches[2]).$matches[3].'>';
1249 1249
                 },
1250 1250
                 $html
1251 1251
             );
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 
1266 1266
         if (\strpos($html, $this->protectedChildNodesHelper) !== false) {
1267 1267
             $html = (string) \preg_replace_callback(
1268
-                '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/',
1268
+                '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/',
1269 1269
                 [$this, 'restoreProtectedHtml'],
1270 1270
                 $html
1271 1271
             );
@@ -1285,14 +1285,14 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
         $html = \str_replace(
1287 1287
             [
1288
-                'html>' . "\n",
1289
-                "\n" . '<html',
1290
-                'html/>' . "\n",
1291
-                "\n" . '</html',
1292
-                'head>' . "\n",
1293
-                "\n" . '<head',
1294
-                'head/>' . "\n",
1295
-                "\n" . '</head',
1288
+                'html>'."\n",
1289
+                "\n".'<html',
1290
+                'html/>'."\n",
1291
+                "\n".'</html',
1292
+                'head>'."\n",
1293
+                "\n".'<head',
1294
+                'head/>'."\n",
1295
+                "\n".'</head',
1296 1296
             ],
1297 1297
             [
1298 1298
                 'html>',
@@ -1311,11 +1311,11 @@  discard block
 block discarded – undo
1311 1311
         $replace = [];
1312 1312
         $replacement = [];
1313 1313
         foreach (self::$selfClosingTags as $selfClosingTag) {
1314
-            $replace[] = '<' . $selfClosingTag . '/>';
1315
-            $replacement[] = '<' . $selfClosingTag . '>';
1316
-            $replace[] = '<' . $selfClosingTag . ' />';
1317
-            $replacement[] = '<' . $selfClosingTag . '>';
1318
-            $replace[] = '></' . $selfClosingTag . '>';
1314
+            $replace[] = '<'.$selfClosingTag.'/>';
1315
+            $replacement[] = '<'.$selfClosingTag.'>';
1316
+            $replace[] = '<'.$selfClosingTag.' />';
1317
+            $replacement[] = '<'.$selfClosingTag.'>';
1318
+            $replace[] = '></'.$selfClosingTag.'>';
1319 1319
             $replacement[] = '>';
1320 1320
         }
1321 1321
         $html = \str_replace(
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
             $this->protectedChildNodes[$this->protected_tags_counter] = $element->parentNode()->innerHtml();
1507 1507
             $parentNode = $element->getNode()->parentNode;
1508 1508
             if ($parentNode !== null) {
1509
-                $parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
1509
+                $parentNode->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>';
1510 1510
             }
1511 1511
 
1512 1512
             ++$this->protected_tags_counter;
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
             }
1541 1541
 
1542 1542
             $this->protectedChildNodes[$this->protected_tags_counter] = $element->innerhtml;
1543
-            $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
1543
+            $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>';
1544 1544
 
1545 1545
             ++$this->protected_tags_counter;
1546 1546
         }
@@ -1557,11 +1557,11 @@  discard block
 block discarded – undo
1557 1557
                 continue;
1558 1558
             }
1559 1559
 
1560
-            $this->protectedChildNodes[$this->protected_tags_counter] = '<!--' . $text . '-->';
1560
+            $this->protectedChildNodes[$this->protected_tags_counter] = '<!--'.$text.'-->';
1561 1561
 
1562 1562
             /* @var $node \DOMComment */
1563 1563
             $node = $element->getNode();
1564
-            $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>');
1564
+            $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$this->protected_tags_counter.'"></'.$this->protectedChildNodesHelper.'>');
1565 1565
             $parentNode = $element->getNode()->parentNode;
1566 1566
             if ($parentNode !== null) {
1567 1567
                 $parentNode->replaceChild($child, $node);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -470,7 +470,7 @@
 block discarded – undo
470 470
     {
471 471
 		if ($localDomain === ''){
472 472
 			$this->localDomain = $_SERVER['SERVER_NAME'];
473
-		}else{
473
+		} else{
474 474
 			$this->localDomain = rtrim(preg_replace('/(https?:)?\/\//', '', $localDomain), '/');
475 475
 		}
476 476
 
Please login to merge, or discard this patch.
src/voku/helper/HtmlMinInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -115,17 +115,17 @@
 block discarded – undo
115 115
     /**
116 116
      * @return bool
117 117
      */
118
-	public function isDoMakeSameDomainLinksRelative(): bool;
118
+  public function isDoMakeSameDomainLinksRelative(): bool;
119 119
 
120
-	/**
121
-     * @param bool
122
-     */
120
+  /**
121
+   * @param bool
122
+   */
123 123
     public function isLocalDomainSet(): bool;
124 124
 	
125
-	/**
126
-     * @return string
127
-     */
128
-	public function getLocalDomain(): string;
125
+  /**
126
+   * @return string
127
+   */
128
+  public function getLocalDomain(): string;
129 129
 
130 130
     /**
131 131
      * @return array
Please login to merge, or discard this patch.
src/voku/helper/HtmlMinDomObserverOptimizeAttributes.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
                     $attrValue,
68 68
                     $attrName,
69 69
                     'http',
70
-					$attributes,
71
-					$htmlMin
70
+          $attributes,
71
+          $htmlMin
72 72
                 );
73 73
             }
74 74
 
@@ -78,24 +78,24 @@  discard block
 block discarded – undo
78 78
                     $attrName,
79 79
                     'https',
80 80
                     $attributes,
81
-					$htmlMin
81
+          $htmlMin
82 82
                 );
83 83
             }
84 84
 
85 85
             if ($htmlMin->isDoMakeSameDomainLinksRelative()) {
86
-				if (!$htmlMin->isLocalDomainSet()){
87
-					$htmlMin->setLocalDomain();
88
-				}
89
-				$localDomain = $htmlMin->getLocalDomain();
90
-				if (
91
-					(($attrName === 'href') || $attrName === 'src' || $attrName === 'srcset' || $attrName === 'action')
92
-					&&
93
-					!(isset($attributes['rel']) && $attributes['rel'] === 'external')
94
-					&&
95
-					!(isset($attributes['target']) && $attributes['target'] === '_blank')
96
-				) {
97
-					$attrValue = \preg_replace("/^((https?:)?\/\/)?{$localDomain}(?!\w)(\/?)/", '/', $attrValue);
98
-				}
86
+        if (!$htmlMin->isLocalDomainSet()){
87
+          $htmlMin->setLocalDomain();
88
+        }
89
+        $localDomain = $htmlMin->getLocalDomain();
90
+        if (
91
+          (($attrName === 'href') || $attrName === 'src' || $attrName === 'srcset' || $attrName === 'action')
92
+          &&
93
+          !(isset($attributes['rel']) && $attributes['rel'] === 'external')
94
+          &&
95
+          !(isset($attributes['target']) && $attributes['target'] === '_blank')
96
+        ) {
97
+          $attrValue = \preg_replace("/^((https?:)?\/\/)?{$localDomain}(?!\w)(\/?)/", '/', $attrValue);
98
+        }
99 99
             }
100 100
 
101 101
             if ($this->removeAttributeHelper($element->tag, $attrName, $attrValue, $attributes, $htmlMin)) {
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
         string $attrValue,
227 227
         string $attrName,
228 228
         string $scheme,
229
-		array $attributes,
230
-		HtmlMinInterface $htmlMin
229
+    array $attributes,
230
+    HtmlMinInterface $htmlMin
231 231
     ): string {
232 232
         /** @noinspection InArrayCanBeUsedInspection */
233 233
         if (
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             }
84 84
 
85 85
             if ($htmlMin->isDoMakeSameDomainLinksRelative()) {
86
-				if (!$htmlMin->isLocalDomainSet()){
86
+				if (!$htmlMin->isLocalDomainSet()) {
87 87
 					$htmlMin->setLocalDomain();
88 88
 				}
89 89
 				$localDomain = $htmlMin->getLocalDomain();
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             &&
238 238
             !(isset($attributes['target']) && $attributes['target'] === '_blank')
239 239
         ) {
240
-            $attrValue = \str_replace($scheme . '://', '//', $attrValue);
240
+            $attrValue = \str_replace($scheme.'://', '//', $attrValue);
241 241
         }
242 242
 
243 243
         return $attrValue;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                 continue;
267 267
             }
268 268
 
269
-            $attrValue .= \trim($class) . ' ';
269
+            $attrValue .= \trim($class).' ';
270 270
         }
271 271
 
272 272
         return \trim($attrValue);
Please login to merge, or discard this patch.