mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Merge branch 'feature/converturl-rewrite' into develop
This commit is contained in:
commit
d12c8b10a2
|
|
@ -20,7 +20,9 @@ trait ParsedownGravTrait
|
|||
/** @var Pages $pages */
|
||||
protected $pages;
|
||||
|
||||
protected $base_url;
|
||||
/** @var Uri $uri */
|
||||
protected $uri;
|
||||
|
||||
protected $pages_dir;
|
||||
protected $special_chars;
|
||||
protected $twig_link_regex = '/\!*\[(?:.*)\]\((\{([\{%#])\s*(.*?)\s*(?:\2|\})\})\)/';
|
||||
|
|
@ -41,8 +43,8 @@ trait ParsedownGravTrait
|
|||
|
||||
$this->page = $page;
|
||||
$this->pages = $grav['pages'];
|
||||
$this->uri = $grav['uri'];
|
||||
$this->BlockTypes['{'] [] = "TwigTag";
|
||||
$this->base_url = rtrim(self::getGrav()['base_url'] . self::getGrav()['pages']->base(), '/');
|
||||
$this->pages_dir = self::getGrav()['locator']->findResource('page://');
|
||||
$this->special_chars = ['>' => 'gt', '<' => 'lt', '"' => 'quot'];
|
||||
|
||||
|
|
@ -203,23 +205,24 @@ trait ParsedownGravTrait
|
|||
//get the url and parse it
|
||||
$url = parse_url(htmlspecialchars_decode($excerpt['element']['attributes']['src']));
|
||||
|
||||
$this_host = isset($url['host']) && $url['host'] == $this->uri->host();
|
||||
|
||||
// if there is no host set but there is a path, the file is local
|
||||
if (!isset($url['host']) && isset($url['path'])) {
|
||||
if ((!isset($url['host']) || $this_host) && isset($url['path'])) {
|
||||
$path_parts = pathinfo($url['path']);
|
||||
|
||||
// get the local path to page media if possible
|
||||
if ($path_parts['dirname'] == $this->page->url(false, false, false)) {
|
||||
$url['path'] = urldecode($path_parts['basename']);
|
||||
// get the media objects for this page
|
||||
$media = $this->page->media();
|
||||
} else {
|
||||
// see if this is an external page to this one
|
||||
$page_route = str_replace($this->base_url, '', $path_parts['dirname']);
|
||||
$base_url = rtrim(self::getGrav()['base_url_relative'] . self::getGrav()['pages']->base(), '/');
|
||||
$page_route = '/' . ltrim(str_replace($base_url, '', $path_parts['dirname']), '/');
|
||||
|
||||
$ext_page = $this->pages->dispatch($page_route, true);
|
||||
if ($ext_page) {
|
||||
$media = $ext_page->media();
|
||||
$url['path'] = urldecode($path_parts['basename']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +252,7 @@ trait ParsedownGravTrait
|
|||
$medium->urlHash($url['fragment']);
|
||||
}
|
||||
|
||||
$excerpt['element'] = $medium->parseDownElement($title, $alt, $class);
|
||||
$excerpt['element'] = $medium->parseDownElement($title, $alt, $class, true);
|
||||
|
||||
} else {
|
||||
// not a current page media file, see if it needs converting to relative
|
||||
|
|
@ -327,7 +330,7 @@ trait ParsedownGravTrait
|
|||
|
||||
// set path to / if not set
|
||||
if (empty($url['path'])) {
|
||||
$url['path'] = '/';
|
||||
$url['path'] = '';
|
||||
}
|
||||
|
||||
// if special scheme, just return
|
||||
|
|
@ -335,66 +338,11 @@ trait ParsedownGravTrait
|
|||
return $excerpt;
|
||||
}
|
||||
|
||||
// if there is no scheme, the file is local and we'll need to convert that URL
|
||||
if (!isset($url['scheme']) && (count($url) > 0)) {
|
||||
$url['path'] = Uri::convertUrl($this->page, Uri::buildUrl($url), $type,
|
||||
true);
|
||||
} else {
|
||||
$url['path'] = Uri::convertUrl($this->page, $url['path'], $type, true);
|
||||
}
|
||||
|
||||
// URL path already has these now so remove them
|
||||
unset($url['query']);
|
||||
unset($url['fragment']);
|
||||
|
||||
// if absolute urls enabled, add them
|
||||
if (self::getGrav()['config']->get('system.absolute_urls', false)) {
|
||||
$uri = self::getGrav()['uri'];
|
||||
$url['scheme'] = str_replace('://', '', $uri->scheme());
|
||||
$url['host'] = $uri->host();
|
||||
|
||||
if ($uri->port() != 80 && $uri->port() != 443) {
|
||||
$url['port'] = $uri->port();
|
||||
}
|
||||
|
||||
// check if page exists for this route, and if so, check if it has SSL enabled
|
||||
$pages = self::getGrav()['pages'];
|
||||
$routes = $pages->routes();
|
||||
|
||||
// if this is an image, get the proper path
|
||||
$url_bits = pathinfo($url['path']);
|
||||
if (isset($url_bits['extension'])) {
|
||||
$target_path = $url_bits['dirname'];
|
||||
} else {
|
||||
$target_path = $url['path'];
|
||||
}
|
||||
|
||||
// strip base from this path
|
||||
$target_path = str_replace($uri->rootUrl(), '', $target_path);
|
||||
|
||||
// set to / if root
|
||||
if (empty($target_path)) {
|
||||
$target_path = '/';
|
||||
}
|
||||
|
||||
// look to see if this page exists and has ssl enabled
|
||||
if (isset($routes[$target_path])) {
|
||||
$target_page = $pages->get($routes[$target_path]);
|
||||
if ($target_page) {
|
||||
$ssl_enabled = $target_page->ssl();
|
||||
if (isset($ssl_enabled)) {
|
||||
if ($ssl_enabled) {
|
||||
$url['scheme'] = 'https';
|
||||
} else {
|
||||
$url['scheme'] = 'http';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// handle paths and such
|
||||
$url = Uri::convertUrl($this->page, $url, $type);
|
||||
|
||||
// build the URL from the component parts and set it on the element
|
||||
$excerpt['element']['attributes']['href'] = Uri::buildUrl($url);
|
||||
|
||||
}
|
||||
|
||||
return $excerpt;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace Grav\Common\Page\Medium;
|
||||
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Common\Data\Blueprint;
|
||||
|
||||
class ImageMedium extends Medium
|
||||
|
|
@ -136,7 +137,15 @@ class ImageMedium extends Medium
|
|||
*/
|
||||
public function url($reset = true)
|
||||
{
|
||||
$output = preg_replace('|^' . preg_quote(GRAV_ROOT) . '|', '', $this->saveImage());
|
||||
$pages_dir = self::$grav['locator']->findResource('page://');
|
||||
$image_path = self::$grav['locator']->findResource('cache://images', true);
|
||||
$image_dir = self::$grav['locator']->findResource('cache://images', false);
|
||||
|
||||
$output = preg_replace('|^' . preg_quote($pages_dir) . '|', '', $this->saveImage());
|
||||
|
||||
if (Utils::startsWith($output, $image_path)) {
|
||||
$output = '/' . $image_dir . preg_replace('|^' . preg_quote($image_path) . '|', '', $output);
|
||||
}
|
||||
|
||||
if ($reset) {
|
||||
$this->reset();
|
||||
|
|
@ -155,6 +164,7 @@ class ImageMedium extends Medium
|
|||
if (!$this->image) {
|
||||
$this->image();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -261,6 +271,7 @@ class ImageMedium extends Medium
|
|||
if ($this->image) {
|
||||
$this->image();
|
||||
$this->image->clearOperations(); // Clear previously applied operations
|
||||
$this->querystring('');
|
||||
$this->filter();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ class Medium extends Data implements RenderableInterface
|
|||
*/
|
||||
public function querystring($querystring = null, $withQuestionmark = true)
|
||||
{
|
||||
if ($querystring) {
|
||||
if (!is_null($querystring)) {
|
||||
$this->set('querystring', ltrim($querystring, '?&'));
|
||||
|
||||
foreach ($this->alternatives as $alt) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class Uri
|
|||
protected $content_path;
|
||||
protected $extension;
|
||||
protected $host;
|
||||
protected $env;
|
||||
protected $params;
|
||||
protected $path;
|
||||
protected $paths;
|
||||
|
|
@ -41,6 +42,7 @@ class Uri
|
|||
$this->params = [];
|
||||
$this->query = [];
|
||||
$this->name = $this->buildHostname();
|
||||
$this->env = $this->buildEnvironment();
|
||||
$this->port = $this->buildPort();
|
||||
$this->uri = $this->buildUri();
|
||||
$this->scheme = $this->buildScheme();
|
||||
|
|
@ -150,18 +152,23 @@ class Uri
|
|||
* @return string
|
||||
*/
|
||||
private function buildHost()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
private function buildEnvironment()
|
||||
{
|
||||
// set hostname
|
||||
$address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1';
|
||||
|
||||
// check for localhost variations
|
||||
if ($this->name == 'localhost' || $address == '::1' || $address == '127.0.0.1') {
|
||||
$host = 'localhost';
|
||||
$env = 'localhost';
|
||||
} else {
|
||||
$host = $this->name;
|
||||
$env = $this->name;
|
||||
}
|
||||
|
||||
return $host;
|
||||
return $env;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -182,6 +189,7 @@ class Uri
|
|||
$this->params = [];
|
||||
$this->query = [];
|
||||
$this->name = [];
|
||||
$this->env = [];
|
||||
$this->port = [];
|
||||
$this->uri = [];
|
||||
$this->base = [];
|
||||
|
|
@ -189,12 +197,24 @@ class Uri
|
|||
$this->root = [];
|
||||
$this->url = [];
|
||||
|
||||
$params = parse_url($url);
|
||||
$grav = Grav::instance();
|
||||
|
||||
$language = $grav['language'];
|
||||
|
||||
$params = Uri::parseUrl($url);
|
||||
|
||||
$this->name = $params['host'];
|
||||
$this->port = isset($params['port']) ? $params['port'] : '80';
|
||||
|
||||
$this->uri = $params['path'];
|
||||
|
||||
// set active language
|
||||
$uri = $language->setActiveFromUri($this->uri);
|
||||
|
||||
if (isset($params['params'])) {
|
||||
$this->params($params['params']);
|
||||
}
|
||||
|
||||
if (isset($params['query'])) {
|
||||
$this->uri .= '?' . $params['query'];
|
||||
parse_str($params['query'], $this->query);
|
||||
|
|
@ -202,9 +222,11 @@ class Uri
|
|||
|
||||
$this->base = $this->buildBaseUrl();
|
||||
$this->host = $this->buildHost();
|
||||
$this->env = $this->buildEnvironment();
|
||||
$this->root_path = $this->buildRootPath();
|
||||
$this->root = $this->base . $this->root_path;
|
||||
$this->url = $this->base . $this->uri;
|
||||
$this->url = $this->root . $uri;
|
||||
$this->path = $uri;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -529,7 +551,7 @@ class Uri
|
|||
*/
|
||||
public function environment()
|
||||
{
|
||||
return $this->host();
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -675,10 +697,225 @@ class Uri
|
|||
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
|
||||
$pass = ($user || $pass) ? "$pass@" : '';
|
||||
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
|
||||
$params = isset($parsed_url['params']) ? static::buildParams($parsed_url['params']) : '';
|
||||
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
|
||||
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
|
||||
|
||||
return "$scheme$user$pass$host$port$path$query$fragment";
|
||||
return "$scheme$user$pass$host$port$path$params$query$fragment";
|
||||
}
|
||||
|
||||
public static function buildParams($params)
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
$params_string = '';
|
||||
foreach ($params as $key => $value) {
|
||||
$output[] = $key . $grav['config']->get('system.param_sep') . $value;
|
||||
$params_string .= '/' . implode('/', $output);
|
||||
}
|
||||
return $params_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts links from absolute '/' or relative (../..) to a Grav friendly format
|
||||
*
|
||||
* @param Page $page the current page to use as reference
|
||||
* @param string $url the URL as it was written in the markdown
|
||||
* @param string $type the type of URL, image | link
|
||||
* @param null $absolute if null, will use system default, if true will use absolute links internally
|
||||
*
|
||||
* @return string the more friendly formatted url
|
||||
*/
|
||||
public static function convertUrl(Page $page, $url, $type = 'link', $absolute = false)
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
$uri = $grav['uri'];
|
||||
|
||||
// Link processing should prepend language
|
||||
$language = $grav['language'];
|
||||
$language_append = '';
|
||||
if ($type == 'link' && $language->enabled()) {
|
||||
$language_append = $language->getLanguageURLPrefix();
|
||||
}
|
||||
|
||||
// Handle Excerpt style $url array
|
||||
if (is_array($url)) {
|
||||
$url_path = $url['path'];
|
||||
} else {
|
||||
$url_path = $url;
|
||||
}
|
||||
|
||||
$external = false;
|
||||
$base = $grav['base_url_relative'];
|
||||
$base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
|
||||
$pages_dir = $grav['locator']->findResource('page://');
|
||||
|
||||
// if absolute and starts with a base_url move on
|
||||
if (isset($url['scheme']) && Utils::startsWith($url['scheme'], 'http')) {
|
||||
$external = true;
|
||||
} elseif (($base_url != '' && Utils::startsWith($url_path, $base_url)) ||
|
||||
$url_path == '/' ||
|
||||
Utils::startsWith($url_path, '#')) {
|
||||
$url_path = $base_url . $url_path;
|
||||
} else {
|
||||
|
||||
// see if page is relative to this or absolute
|
||||
if (Utils::startsWith($url_path, '/')) {
|
||||
$normalized_url = Utils::normalizePath($base_url . $url_path);
|
||||
$normalized_path = Utils::normalizePath($pages_dir . $url_path);
|
||||
} else {
|
||||
$page_route = ($page->home() && !empty($url_path)) ? $page->rawRoute() : $page->route();
|
||||
$normalized_url = $base_url . Utils::normalizePath($page_route . '/' . $url_path);
|
||||
$normalized_path = Utils::normalizePath($page->path() . '/' . $url_path);
|
||||
}
|
||||
|
||||
// special check to see if path checking is required.
|
||||
$just_path = str_replace($normalized_url, '', $normalized_path);
|
||||
if ($just_path == $page->path() || $normalized_url == '/') {
|
||||
$url_path = $normalized_url;
|
||||
} else {
|
||||
$url_bits = static::parseUrl($normalized_path);
|
||||
$full_path = ($url_bits['path']);
|
||||
$raw_full_path = rawurldecode($full_path);
|
||||
|
||||
if (file_exists($raw_full_path)) {
|
||||
$full_path = $raw_full_path;
|
||||
} elseif (file_exists($full_path)) {
|
||||
// do nothing
|
||||
} else {
|
||||
$full_path = false;
|
||||
}
|
||||
|
||||
if ($full_path) {
|
||||
$path_info = pathinfo($full_path);
|
||||
$page_path = $path_info['dirname'];
|
||||
$filename = '';
|
||||
|
||||
if ($url_path == '..') {
|
||||
$page_path = $full_path;
|
||||
} else {
|
||||
// save the filename if a file is part of the path
|
||||
if (is_file($full_path)) {
|
||||
if ($path_info['extension'] != 'md') {
|
||||
$filename = '/' . $path_info['basename'];
|
||||
}
|
||||
} else {
|
||||
$page_path = $full_path;
|
||||
}
|
||||
}
|
||||
|
||||
// get page instances and try to find one that fits
|
||||
$instances = $grav['pages']->instances();
|
||||
if (isset($instances[$page_path])) {
|
||||
/** @var Page $target */
|
||||
$target = $instances[$page_path];
|
||||
$url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
|
||||
|
||||
$url_path = Uri::buildUrl($url_bits);
|
||||
} else {
|
||||
$url_path = $normalized_url;
|
||||
}
|
||||
} else {
|
||||
$url_path = $normalized_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle absolute URLs
|
||||
if (!$external && ($absolute === true || $grav['config']->get('system.absolute_urls', false))) {
|
||||
|
||||
$url['scheme'] = str_replace('://', '', $uri->scheme());
|
||||
$url['host'] = $uri->host();
|
||||
|
||||
if ($uri->port() != 80 && $uri->port() != 443) {
|
||||
$url['port'] = $uri->port();
|
||||
}
|
||||
|
||||
// check if page exists for this route, and if so, check if it has SSL enabled
|
||||
$pages = $grav['pages'];
|
||||
$routes = $pages->routes();
|
||||
|
||||
// if this is an image, get the proper path
|
||||
$url_bits = pathinfo($url_path);
|
||||
if (isset($url_bits['extension'])) {
|
||||
$target_path = $url_bits['dirname'];
|
||||
} else {
|
||||
$target_path = $url_path;
|
||||
}
|
||||
|
||||
// strip base from this path
|
||||
$target_path = str_replace($uri->rootUrl(), '', $target_path);
|
||||
|
||||
// set to / if root
|
||||
if (empty($target_path)) {
|
||||
$target_path = '/';
|
||||
}
|
||||
|
||||
// look to see if this page exists and has ssl enabled
|
||||
if (isset($routes[$target_path])) {
|
||||
$target_page = $pages->get($routes[$target_path]);
|
||||
if ($target_page) {
|
||||
$ssl_enabled = $target_page->ssl();
|
||||
if (isset($ssl_enabled)) {
|
||||
if ($ssl_enabled) {
|
||||
$url['scheme'] = 'https';
|
||||
} else {
|
||||
$url['scheme'] = 'http';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// transform back to string/array as needed
|
||||
if (is_array($url)) {
|
||||
$url['path'] = $url_path;
|
||||
} else {
|
||||
$url = $url_path;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function parseUrl($url)
|
||||
{
|
||||
$bits = parse_url($url);
|
||||
|
||||
$grav = Grav::instance();
|
||||
|
||||
list($stripped_path, $params) = static::extractParams($bits['path'], $grav['config']->get('system.param_sep'));
|
||||
|
||||
if (!empty($params)) {
|
||||
$bits['path'] = $stripped_path;
|
||||
$bits['params'] = $params;
|
||||
}
|
||||
|
||||
return $bits;
|
||||
}
|
||||
|
||||
public static function extractParams($uri, $delimiter)
|
||||
{
|
||||
$params = [];
|
||||
|
||||
if (strpos($uri, $delimiter) !== false) {
|
||||
$bits = explode('/', $uri);
|
||||
$path = [];
|
||||
foreach ($bits as $bit) {
|
||||
if (strpos($bit, $delimiter) !== false) {
|
||||
$param = explode($delimiter, $bit);
|
||||
if (count($param) == 2) {
|
||||
$plain_var = filter_var(rawurldecode($param[1]), FILTER_SANITIZE_STRING);
|
||||
$params[$param[0]] = $plain_var;
|
||||
}
|
||||
} else {
|
||||
$path[] = $bit;
|
||||
}
|
||||
}
|
||||
$uri = '/' . ltrim(implode('/', $path), '/');
|
||||
}
|
||||
|
||||
return [$uri, $params];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -691,7 +928,7 @@ class Uri
|
|||
*
|
||||
* @return string the more friendly formatted url
|
||||
*/
|
||||
public static function convertUrl(Page $page, $markdown_url, $type = 'link', $relative = null)
|
||||
public static function convertUrlOld(Page $page, $markdown_url, $type = 'link', $relative = null)
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
|
|
|
|||
BIN
tests/fake/nested-site/user/pages/01.item1/existing-file.zip
Normal file
BIN
tests/fake/nested-site/user/pages/01.item1/existing-file.zip
Normal file
Binary file not shown.
BIN
tests/fake/nested-site/user/pages/01.item1/home-cache-image.jpg
Normal file
BIN
tests/fake/nested-site/user/pages/01.item1/home-cache-image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
BIN
tests/fake/nested-site/user/pages/01.item1/home-sample-image.jpg
Normal file
BIN
tests/fake/nested-site/user/pages/01.item1/home-sample-image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
|
|
@ -5,8 +5,8 @@ use Grav\Common\Grav;
|
|||
use Grav\Common\Uri;
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Markdown\Parsedown;
|
||||
use Grav\Common\Language\Language;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -29,6 +29,9 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
/** @var Uri $uri */
|
||||
protected $uri;
|
||||
|
||||
/** @var Language $language */
|
||||
protected $language;
|
||||
|
||||
static $run = false;
|
||||
|
||||
protected function _before()
|
||||
|
|
@ -37,6 +40,13 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->pages = $this->grav['pages'];
|
||||
$this->config = $this->grav['config'];
|
||||
$this->uri = $this->grav['uri'];
|
||||
$this->language = $this->grav['language'];
|
||||
$this->config->set('system.home.alias', '/item1');
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->config->set('system.languages.supported', []);
|
||||
|
||||
unset($this->grav['language']);
|
||||
$this->grav['language'] = new Language($this->grav);
|
||||
|
||||
if (!self::$run) {
|
||||
/** @var UniformResourceLocator $locator */
|
||||
|
|
@ -61,104 +71,341 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
{
|
||||
}
|
||||
|
||||
public function testAnchorLinksNoPortRelativeUrls()
|
||||
public function testImages()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-1/#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
// $this->assertSame('<p><a href="#foo">Current Anchor</a></p>',
|
||||
// $this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
$this->assertSame('<p><img src="/02.item2/02.item2-2/sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="/item2/item2-2/missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="/home-missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
|
||||
$this->config->set('system.languages.supported', ['fr','en']);
|
||||
unset($this->grav['language']);
|
||||
$this->grav['language'] = new Language($this->grav);
|
||||
$this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><img src="/02.item2/02.item2-2/sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
}
|
||||
|
||||
public function testImagesSubDir()
|
||||
{
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertRegexp('|<p><img src="\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="/subdir/02.item2/02.item2-2/sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="/subdir/item2/item2-2/missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="/subdir/home-missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
|
||||
}
|
||||
|
||||
public function testAnchorLinksNoPortAbsoluteUrls()
|
||||
public function testImagesAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://localhost/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->assertSame('<p><img src="http://testing.dev/02.item2/02.item2-2/sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="http:\/\/testing.dev\/images\/.*-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="http:\/\/testing.dev\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="http://testing.dev/item2/item2-2/missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="http://testing.dev/home-missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
}
|
||||
|
||||
public function testImagesSubDirAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><img src="http://testing.dev/subdir/02.item2/02.item2-2/sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="http:\/\/testing.dev\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="http:\/\/testing.dev\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="http://testing.dev/subdir/item2/item2-2/missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="http://testing.dev/subdir/home-missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
}
|
||||
|
||||
public function testRootImages()
|
||||
{
|
||||
$this->uri->initializeWithURL('http://testing.dev/')->init();
|
||||
|
||||
$defaults = [
|
||||
'extra' => false,
|
||||
'auto_line_breaks' => false,
|
||||
'auto_url_links' => false,
|
||||
'escape_markup' => false,
|
||||
'special_chars' => ['>' => 'gt', '<' => 'lt'],
|
||||
];
|
||||
$page = $this->pages->dispatch('/');
|
||||
$this->parsedown = new Parsedown($page, $defaults);
|
||||
|
||||
$this->assertSame('<p><img src="/01.item1/home-sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="\/images\/.*-home-cache-image.jpe?g\?foo=1" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="/home-missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
|
||||
$this->config->set('system.languages.supported', ['fr','en']);
|
||||
unset($this->grav['language']);
|
||||
$this->grav['language'] = new Language($this->grav);
|
||||
$this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><img src="/01.item1/home-sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testRootImagesSubDirAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><img src="http://testing.dev/subdir/02.item2/02.item2-2/sample-image.jpg" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="http:\/\/testing.dev\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertRegexp('|<p><img src="http:\/\/testing.dev\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="http://testing.dev/subdir/item2/item2-2/missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
$this->assertSame('<p><img src="http://testing.dev/subdir/home-missing-image.jpg" alt="" /></p>',
|
||||
$this->parsedown->text(''));
|
||||
}
|
||||
|
||||
public function testRootAbsoluteLinks()
|
||||
{
|
||||
$this->uri->initializeWithURL('http://testing.dev/')->init();
|
||||
|
||||
$defaults = [
|
||||
'extra' => false,
|
||||
'auto_line_breaks' => false,
|
||||
'auto_url_links' => false,
|
||||
'escape_markup' => false,
|
||||
'special_chars' => ['>' => 'gt', '<' => 'lt'],
|
||||
];
|
||||
$page = $this->pages->dispatch('/');
|
||||
$this->parsedown = new Parsedown($page, $defaults);
|
||||
|
||||
|
||||
$this->assertSame('<p><a href="/item1/item1-3">Down a Level</a></p>',
|
||||
$this->parsedown->text('[Down a Level](item1-3)'));
|
||||
|
||||
$this->assertSame('<p><a href="/item2">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../item2)'));
|
||||
|
||||
$this->assertSame('<p><a href="/?foo=bar">With Query</a></p>',
|
||||
$this->parsedown->text('[With Query](?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/foo:bar">With Param</a></p>',
|
||||
$this->parsedown->text('[With Param](/foo:bar)'));
|
||||
$this->assertSame('<p><a href="/#foo">With Anchor</a></p>',
|
||||
$this->parsedown->text('[With Anchor](#foo)'));
|
||||
|
||||
$this->config->set('system.languages.supported', ['fr','en']);
|
||||
unset($this->grav['language']);
|
||||
$this->grav['language'] = new Language($this->grav);
|
||||
$this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/fr/item2">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../item2)'));
|
||||
$this->assertSame('<p><a href="/fr/item1/item1-3">Down a Level</a></p>',
|
||||
$this->parsedown->text('[Down a Level](item1-3)'));
|
||||
$this->assertSame('<p><a href="/fr/?foo=bar">With Query</a></p>',
|
||||
$this->parsedown->text('[With Query](?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/fr/foo:bar">With Param</a></p>',
|
||||
$this->parsedown->text('[With Param](/foo:bar)'));
|
||||
$this->assertSame('<p><a href="/fr/#foo">With Anchor</a></p>',
|
||||
$this->parsedown->text('[With Anchor](#foo)'));
|
||||
}
|
||||
|
||||
|
||||
public function testAnchorLinksLangRelativeUrls()
|
||||
{
|
||||
$this->config->set('system.languages.supported', ['fr','en']);
|
||||
unset($this->grav['language']);
|
||||
$this->grav['language'] = new Language($this->grav);
|
||||
$this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/fr/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="/fr/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
$this->assertSame('<p><a href="/fr/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item2/item2-1/#foo">Peer Anchor 2</a></p>',
|
||||
$this->assertSame('<p><a href="/fr/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
// $this->assertSame('<p><a href="#foo">Current Anchor</a></p>',
|
||||
// $this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://localhost/#foo">Root Anchor</a></p>',
|
||||
|
||||
}
|
||||
|
||||
public function testAnchorLinksLangAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->config->set('system.languages.supported', ['fr','en']);
|
||||
unset($this->grav['language']);
|
||||
$this->grav['language'] = new Language($this->grav);
|
||||
$this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://testing.dev/fr/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/fr/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/fr/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/fr/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testExternalLinks()
|
||||
{
|
||||
$this->assertSame('<p><a href="http://www.cnn.com">cnn.com</a></p>',
|
||||
$this->parsedown->text('[cnn.com](http://www.cnn.com)'));
|
||||
$this->assertSame('<p><a href="https://www.google.com">google.com</a></p>',
|
||||
$this->parsedown->text('[google.com](https://www.google.com)'));
|
||||
}
|
||||
|
||||
public function testExternalLinksSubDir()
|
||||
{
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://www.cnn.com">cnn.com</a></p>',
|
||||
$this->parsedown->text('[cnn.com](http://www.cnn.com)'));
|
||||
$this->assertSame('<p><a href="https://www.google.com">google.com</a></p>',
|
||||
$this->parsedown->text('[google.com](https://www.google.com)'));
|
||||
}
|
||||
|
||||
public function testExternalLinksSubDirAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://www.cnn.com">cnn.com</a></p>',
|
||||
$this->parsedown->text('[cnn.com](http://www.cnn.com)'));
|
||||
$this->assertSame('<p><a href="https://www.google.com">google.com</a></p>',
|
||||
$this->parsedown->text('[google.com](https://www.google.com)'));
|
||||
}
|
||||
|
||||
public function testAnchorLinksRelativeUrls()
|
||||
{
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
}
|
||||
|
||||
public function testAnchorLinksAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function testAnchorLinksWithPortAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithURL('http://localhost:8080/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev:8080/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://localhost:8080/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev:8080/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="http://localhost:8080/item2/item2-1/#foo">Peer Anchor 2</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev:8080/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
// $this->assertSame('<p><a href="http://localhost:8080#foo">Current Anchor</a></p>',
|
||||
// $this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://localhost:8080/#foo">Root Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev:8080/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev:8080/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
|
||||
}
|
||||
|
||||
public function testAnchorLinksSubDirRelativeUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-1/#foo">Peer Anchor 2</a></p>',
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
// $this->assertSame('<p><a href="/subdir/#foo">Current Anchor</a></p>',
|
||||
// $this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="/subdir/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
|
||||
}
|
||||
|
||||
public function testAnchorLinksSubDirAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor](../item2-1#foo)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-1/#foo">Peer Anchor 2</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-1#foo">Peer Anchor 2</a></p>',
|
||||
$this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)'));
|
||||
// $this->assertSame('<p><a href="http://localhost/subdir#foo">Current Anchor</a></p>',
|
||||
// $this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/#foo">Root Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2#foo">Current Anchor</a></p>',
|
||||
$this->parsedown->text('[Current Anchor](#foo)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/#foo">Root Anchor</a></p>',
|
||||
$this->parsedown->text('[Root Anchor](/#foo)'));
|
||||
|
||||
}
|
||||
|
||||
public function testSlugRelativeLinks()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/">Up to Root Level</a></p>',
|
||||
$this->parsedown->text('[Up to Root Level](../..)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../item2-1)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->parsedown->text('[Down a Level](item2-2-1)'));
|
||||
$this->assertSame('<p><a href="/item2">Up a Level</a></p>',
|
||||
$this->parsedown->text('[Up a Level](..)'));
|
||||
// $this->assertSame('<p><a href="/">Up to Root Level</a></p>',
|
||||
// $this->parsedown->text('[Up to Root Level](../..)'));
|
||||
$this->assertSame('<p><a href="/item3/item3-3">Up and Down</a></p>',
|
||||
$this->parsedown->text('[Up and Down](../../item3/item3-3)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)'));
|
||||
// $this->assertSame('<p><a href="/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
// $this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
|
|
@ -170,34 +417,33 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
public function testSlugRelativeLinksAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://localhost/item2/item2-1">Peer Page</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../item2-1)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->parsedown->text('[Down a Level](item2-2-1)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item2">Up a Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2">Up a Level</a></p>',
|
||||
$this->parsedown->text('[Up a Level](..)'));
|
||||
// $this->assertSame('<p><a href="http://localhost/">Up to Root Level</a></p>',
|
||||
// $this->parsedown->text('[Up to Root Level](../..)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item3/item3-3">Up and Down</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/">Up to Root Level</a></p>',
|
||||
$this->parsedown->text('[Up to Root Level](../..)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/item3/item3-3">Up and Down</a></p>',
|
||||
$this->parsedown->text('[Up and Down](../../item3/item3-3)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)'));
|
||||
// $this->assertSame('<p><a href="/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
// $this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/item3/item3-3#foo">Up and Down with Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/item3/item3-3#foo">Up and Down with Anchor</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)'));
|
||||
}
|
||||
|
||||
public function testSlugRelativeLinksSubDir()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../item2-1)'));
|
||||
|
|
@ -211,8 +457,8 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->parsedown->text('[Up and Down](../../item3/item3-3)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)'));
|
||||
// $this->assertSame('<p><a href="/subdir/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
// $this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/subdir/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/subdir/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
|
|
@ -224,35 +470,37 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
public function testSlugRelativeLinksSubDirAbsoluteUrls()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-1">Peer Page</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../item2-1)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->parsedown->text('[Down a Level](item2-2-1)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2">Up a Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2">Up a Level</a></p>',
|
||||
$this->parsedown->text('[Up a Level](..)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir">Up to Root Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir">Up to Root Level</a></p>',
|
||||
$this->parsedown->text('[Up to Root Level](../..)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item3/item3-3">Up and Down</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item3/item3-3">Up and Down</a></p>',
|
||||
$this->parsedown->text('[Up and Down](../../item3/item3-3)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)'));
|
||||
// $this->assertSame('<p><a href="http://localhost/subdir/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
// $this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2?foo=bar">Up a Level with Query</a></p>',
|
||||
$this->parsedown->text('[Up a Level with Query](../?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item3/item3-3#foo">Up and Down with Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item3/item3-3#foo">Up and Down with Anchor</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)'));
|
||||
}
|
||||
|
||||
|
||||
public function testDirectoryRelativeLinks()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](../01.item2-1)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
|
|
@ -263,20 +511,17 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->parsedown->text('[Down a Level with Query](01.item2-2-1?foo=bar)'));
|
||||
$this->assertSame('<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Query](../../03.item3/03.item3-3?foo=bar)'));
|
||||
// $this->assertSame('<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
|
||||
// $this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)'));
|
||||
$this->assertSame('<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>',
|
||||
$this->parsedown->text('[Up and Down with Anchor](../../03.item3/03.item3-3#foo)'));
|
||||
|
||||
}
|
||||
|
||||
public function testDirectoryAbsoluteLinks()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
|
||||
// $this->assertSame('<p><a href="/">Root</a></p>',
|
||||
// $this->parsedown->text('[Root](/)'));
|
||||
public function testAbsoluteLinks()
|
||||
{
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/">Root</a></p>',
|
||||
$this->parsedown->text('[Root](/)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](/item2/item2-1)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
|
|
@ -289,16 +534,14 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->parsedown->text('[With Param](/item2/foo:bar)'));
|
||||
$this->assertSame('<p><a href="/item2#foo">With Anchor</a></p>',
|
||||
$this->parsedown->text('[With Anchor](/item2#foo)'));
|
||||
|
||||
}
|
||||
|
||||
public function testDirectoryAbsoluteLinksSubDir()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
// $this->assertSame('<p><a href="/subdir/">Root</a></p>',
|
||||
// $this->parsedown->text('[Root](/)'));
|
||||
$this->assertSame('<p><a href="/subdir/">Root</a></p>',
|
||||
$this->parsedown->text('[Root](/)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](/item2/item2-1)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
|
|
@ -311,34 +554,61 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->parsedown->text('[With Param](/item2/foo:bar)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2#foo">With Anchor</a></p>',
|
||||
$this->parsedown->text('[With Anchor](/item2#foo)'));
|
||||
|
||||
}
|
||||
|
||||
public function testDirectoryAbsoluteLinksSubDirAbsoluteUrl()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://localhost/subdir/item2/item-2-2', '/subdir')->init();
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
// $this->assertSame('<p><a href="http://localhost/subdir/">Root</a></p>',
|
||||
// $this->parsedown->text('[Root](/)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-1">Peer Page</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/">Root</a></p>',
|
||||
$this->parsedown->text('[Root](/)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-1">Peer Page</a></p>',
|
||||
$this->parsedown->text('[Peer Page](/item2/item2-1)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
|
||||
$this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2">Up a Level</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2">Up a Level</a></p>',
|
||||
$this->parsedown->text('[Up a Level](/item2)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2?foo=bar">With Query</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2?foo=bar">With Query</a></p>',
|
||||
$this->parsedown->text('[With Query](/item2?foo=bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2/foo:bar">With Param</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/foo:bar">With Param</a></p>',
|
||||
$this->parsedown->text('[With Param](/item2/foo:bar)'));
|
||||
$this->assertSame('<p><a href="http://localhost/subdir/item2#foo">With Anchor</a></p>',
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2#foo">With Anchor</a></p>',
|
||||
$this->parsedown->text('[With Anchor](/item2#foo)'));
|
||||
}
|
||||
|
||||
public function testSpecialProtocols()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="mailto:user@domain.com">mailto</a></p>',
|
||||
$this->parsedown->text('[mailto](mailto:user@domain.com)'));
|
||||
$this->assertSame('<p><a href="xmpp:xyx@domain.com">xmpp</a></p>',
|
||||
$this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'));
|
||||
$this->assertSame('<p><a href="tel:123-555-12345">tel</a></p>',
|
||||
$this->parsedown->text('[tel](tel:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="sms:123-555-12345">sms</a></p>',
|
||||
$this->parsedown->text('[sms](sms:123-555-12345)'));
|
||||
}
|
||||
|
||||
public function testSpecialProtocolsSubDir()
|
||||
{
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="mailto:user@domain.com">mailto</a></p>',
|
||||
$this->parsedown->text('[mailto](mailto:user@domain.com)'));
|
||||
$this->assertSame('<p><a href="xmpp:xyx@domain.com">xmpp</a></p>',
|
||||
$this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'));
|
||||
$this->assertSame('<p><a href="tel:123-555-12345">tel</a></p>',
|
||||
$this->parsedown->text('[tel](tel:123-555-12345)'));
|
||||
$this->assertSame('<p><a href="sms:123-555-12345">sms</a></p>',
|
||||
$this->parsedown->text('[sms](sms:123-555-12345)'));
|
||||
}
|
||||
|
||||
public function testSpecialProtocolsSubDirAbsoluteUrl()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="mailto:user@domain.com">mailto</a></p>',
|
||||
$this->parsedown->text('[mailto](mailto:user@domain.com)'));
|
||||
|
|
@ -352,8 +622,7 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
|
||||
public function testReferenceLinks()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$sample = '[relative link][r_relative]
|
||||
[r_relative]: ../item2-3#blah';
|
||||
|
|
@ -371,18 +640,9 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->parsedown->text($sample));
|
||||
}
|
||||
|
||||
public function testExternalLinks()
|
||||
{
|
||||
$this->assertSame('<p><a href="http://www.cnn.com">cnn.com</a></p>',
|
||||
$this->parsedown->text('[cnn.com](http://www.cnn.com)'));
|
||||
$this->assertSame('<p><a href="https://www.google.com">google.com</a></p>',
|
||||
$this->parsedown->text('[google.com](https://www.google.com)'));
|
||||
}
|
||||
|
||||
public function testAttributeLinks()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', false);
|
||||
$this->uri->initializeWithURL('http://localhost/item2/item-2-2')->init();
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/item2/item2-3" class="button">Relative Class</a></p>',
|
||||
$this->parsedown->text('[Relative Class](../item2-3?classes=button)'));
|
||||
|
|
@ -400,6 +660,43 @@ class MarkdownTest extends \Codeception\TestCase\Test
|
|||
$this->parsedown->text('[Relative Mixed](../item2-3?foo=bar&baz=qux&rel=nofollow&class=button)'));
|
||||
}
|
||||
|
||||
public function testInvalidLinks()
|
||||
{
|
||||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/item2/item2-2/no-page">Non Existent Page</a></p>',
|
||||
$this->parsedown->text('[Non Existent Page](no-page)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-2/existing-file.zip">Existent File</a></p>',
|
||||
$this->parsedown->text('[Existent File](existing-file.zip)'));
|
||||
$this->assertSame('<p><a href="/item2/item2-2/missing-file.zip">Non Existent File</a></p>',
|
||||
$this->parsedown->text('[Non Existent File](missing-file.zip)'));
|
||||
}
|
||||
|
||||
public function testInvalidLinksSubDir()
|
||||
{
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-2/no-page">Non Existent Page</a></p>',
|
||||
$this->parsedown->text('[Non Existent Page](no-page)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-2/existing-file.zip">Existent File</a></p>',
|
||||
$this->parsedown->text('[Existent File](existing-file.zip)'));
|
||||
$this->assertSame('<p><a href="/subdir/item2/item2-2/missing-file.zip">Non Existent File</a></p>',
|
||||
$this->parsedown->text('[Non Existent File](missing-file.zip)'));
|
||||
}
|
||||
|
||||
public function testInvalidLinksSubDirAbsoluteUrl()
|
||||
{
|
||||
$this->config->set('system.absolute_urls', true);
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
|
||||
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/no-page">Non Existent Page</a></p>',
|
||||
$this->parsedown->text('[Non Existent Page](no-page)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/existing-file.zip">Existent File</a></p>',
|
||||
$this->parsedown->text('[Existent File](existing-file.zip)'));
|
||||
$this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/missing-file.zip">Non Existent File</a></p>',
|
||||
$this->parsedown->text('[Non Existent File](missing-file.zip)'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user