Loading pathologic.module +4 −3 Original line number Diff line number Diff line Loading @@ -325,7 +325,8 @@ function _pathologic_replace($matches) { $url_params = [ 'path' => $parts['path'], 'options' => [ 'query' => $parts['qparts'], // Force the query to an array if it's unspecified. 'query' => $parts['qparts'] ?: [], 'path_processing' => TRUE, 'fragment' => isset($parts['fragment']) ? $parts['fragment'] : NULL, // Create an absolute URL if protocol_style is 'full' or 'proto-rel', but Loading Loading @@ -359,9 +360,9 @@ function _pathologic_replace($matches) { $url = Url::fromRoute('<front>', [], $url_params['options'])->toString(); } else { $path = (empty($url_params['options']['external']) ? 'base:/' : '') . $url_params['path']; try { $url = Url::fromUri('base:/' . $url_params['path'], $url_params['options']) ->toString(); $url = Url::fromUri($path, $url_params['options'])->toString(); } catch (\Exception $e) { // In case of an error, e.g. completely invalid URL, return it unchanged. Loading tests/modules/pathologic_test/pathologic_test.module +4 −0 Original line number Diff line number Diff line Loading @@ -15,5 +15,9 @@ function pathologic_test_pathologic_alter(&$url_params, $parts, $settings) { elseif ($parts['qparts']['test'] === 'use_original') { $url_params['options']['use_original'] = TRUE; } elseif ($parts['qparts']['test'] === 'external') { $url_params['path'] = 'http://cdn.example.com/' . $url_params['path']; $url_params['options']['external'] = TRUE; } } } tests/src/Functional/PathologicTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -217,6 +217,10 @@ class PathologicTest extends BrowserTestBase { '<a href="bar?test=use_original">', t('hook_pathologic_alter(): Passthrough with use_original option') ); $this->assertEquals( check_markup('<a href="bar?test=external">', $format_id), '<a href="http://cdn.example.com/bar?test=external">', ); // Test paths to existing files when clean URLs are disabled. // @see http://drupal.org/node/1672430 Loading Loading
pathologic.module +4 −3 Original line number Diff line number Diff line Loading @@ -325,7 +325,8 @@ function _pathologic_replace($matches) { $url_params = [ 'path' => $parts['path'], 'options' => [ 'query' => $parts['qparts'], // Force the query to an array if it's unspecified. 'query' => $parts['qparts'] ?: [], 'path_processing' => TRUE, 'fragment' => isset($parts['fragment']) ? $parts['fragment'] : NULL, // Create an absolute URL if protocol_style is 'full' or 'proto-rel', but Loading Loading @@ -359,9 +360,9 @@ function _pathologic_replace($matches) { $url = Url::fromRoute('<front>', [], $url_params['options'])->toString(); } else { $path = (empty($url_params['options']['external']) ? 'base:/' : '') . $url_params['path']; try { $url = Url::fromUri('base:/' . $url_params['path'], $url_params['options']) ->toString(); $url = Url::fromUri($path, $url_params['options'])->toString(); } catch (\Exception $e) { // In case of an error, e.g. completely invalid URL, return it unchanged. Loading
tests/modules/pathologic_test/pathologic_test.module +4 −0 Original line number Diff line number Diff line Loading @@ -15,5 +15,9 @@ function pathologic_test_pathologic_alter(&$url_params, $parts, $settings) { elseif ($parts['qparts']['test'] === 'use_original') { $url_params['options']['use_original'] = TRUE; } elseif ($parts['qparts']['test'] === 'external') { $url_params['path'] = 'http://cdn.example.com/' . $url_params['path']; $url_params['options']['external'] = TRUE; } } }
tests/src/Functional/PathologicTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -217,6 +217,10 @@ class PathologicTest extends BrowserTestBase { '<a href="bar?test=use_original">', t('hook_pathologic_alter(): Passthrough with use_original option') ); $this->assertEquals( check_markup('<a href="bar?test=external">', $format_id), '<a href="http://cdn.example.com/bar?test=external">', ); // Test paths to existing files when clean URLs are disabled. // @see http://drupal.org/node/1672430 Loading