Ejemplo n.º 1
0
 public function testReplace()
 {
     $url = 'https://www.google.de/search?num=30&site=&source=hp&q=software+development&oq=Software+Development&gs_l=hp.3.0.0l10.464.4794.0.5387.31.18.3.7.8.0.185.1953.1j14.15.0....0...1c.1.64.hp..8.23.1779.0._BnKQF4413M';
     $wildcard = 'search';
     $this->assertEquals('https://www.google.de/?num=30&site=&source=hp&q=software+development&oq=Software+Development&gs_l=hp.3.0.0l10.464.4794.0.5387.31.18.3.7.8.0.185.1953.1j14.15.0....0...1c.1.64.hp..8.23.1779.0._BnKQF4413M', \tzfrs\URLPruner\Pruners\RegexPruner::replace($url, $wildcard));
 }
Ejemplo n.º 2
0
 /**
  * This method prunes the URL by applying all options that have been set previously.
  *
  * If the user didn't set any options we can simply return the URL. Otherwise we iterate over each option the user
  * "activated" and call the respective class with the function.
  * After all options have been applied we can return the URL
  *
  * @param $url
  * @return string
  */
 public function prune($url)
 {
     if ($this->options === null) {
         return $url;
     }
     foreach ($this->options as $option => $value) {
         switch ($option) {
             case 'anythingAfter':
                 $url = StringPruner::anythingAfter($url, $value);
                 break;
             case 'regex':
                 $url = RegexPruner::replace($url, $value);
                 break;
             case 'params_all':
                 $url = ParamPruner::all($url);
                 break;
             case 'params':
                 $url = ParamPruner::keys($url, $value);
                 break;
             case 'params_values':
                 $url = ParamPruner::values($url, $value);
                 break;
         }
     }
     // Reset
     $this->options = null;
     return $url;
 }
Ejemplo n.º 3
0
 public function testReservedChar()
 {
     $url = 'http://hostname/something.html#anchor-5';
     $wildcard = '#anchor';
     $this->assertEquals('http://hostname/something.html-5', \tzfrs\URLPruner\Pruners\RegexPruner::replace($url, $wildcard));
 }