You are here

function _pathologic_content_url in Pathologic 8

Wrapper around url() which does HTML entity decoding and encoding.

Since Pathologic works with paths in content, it needs to decode paths which have been HTML-encoded, and re-encode them when done. This is a wrapper around url() which does the same thing so that we can expect the results from it and from Pathologic to still match in our tests.

See also

url()

http://drupal.org/node/1672932

http://www.w3.org/TR/xhtml1/guidelines.html#C_12

1 call to _pathologic_content_url()
PathologicTest::testPathologic in tests/src/Functional/PathologicTest.php

File

tests/src/Functional/PathologicTest.php, line 278

Namespace

Drupal\Tests\pathologic\Functional

Code

function _pathologic_content_url($path, $options) {

  // If we should pretend this is a path to a file, make url() behave like clean
  // URLs are enabled.
  // @see _pathologic_replace()
  // @see http://drupal.org/node/1672430
  if (!empty($options['is_file'])) {
    $options['script_path'] = '';
  }
  if (parse_url($path, PHP_URL_SCHEME) === NULL) {
    if ($path == '<front>') {
      return Html::escape(Url::fromRoute('<front>', [], $options)
        ->toString());
    }
    $path = 'base://' . $path;
  }
  return Html::escape(Url::fromUri(htmlspecialchars_decode($path), $options)
    ->toString());
}