You are here

function _pathologic_url_to_protocol_relative in Pathologic 7.3

Same name and namespace in other branches
  1. 8 pathologic.module \_pathologic_url_to_protocol_relative()
  2. 7.2 pathologic.module \_pathologic_url_to_protocol_relative()

Convert a full URL with a protocol to a protocol-relative URL.

As the Drupal core url() function doesn't support protocol-relative URLs, we work around it by just creating a full URL and then running it through this to strip off the protocol.

Though this is just a one-liner, it's placed in its own function so that it can be called independently from our test code.

2 calls to _pathologic_url_to_protocol_relative()
PathologicTestCase::testPathologic in tests/pathologic.test
_pathologic_replace in ./pathologic.module
Process and replace paths. preg_replace_callback() callback.

File

./pathologic.module, line 500
Pathologic text filter for Drupal.

Code

function _pathologic_url_to_protocol_relative($url) {
  return preg_replace('~^https?://~', '//', $url);
}