Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add anchor check #2070

Merged
merged 3 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 1.8.0 (10. Novemeber 2020)
## 1.8.0 (24. Novemeber 2020)

+ [#2069](https://github.com/luyadev/luya/issues/2069) `WebsiteLink` does not prepend the URL protocol when an acnhor link `#foo-bar` is provided.
+ [#2067](https://github.com/luyadev/luya/pull/2067) Added new `['sort' => false]` option to ExportHelper::csv() and ExportHelper::xls().

## 1.7.1 (23. September 2020)
Expand Down
3 changes: 3 additions & 0 deletions core/web/WebsiteLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function setHref($href)
{
if (StringHelper::startsWith($href, '//')) {
$this->_href = Url::base(true) . str_replace('//', '/', $href);
} elseif (StringHelper::startsWith($href, '#')) {
// When an anchor link is given, do not modify the link. This can be usefull for one pagers
$this->_href = $href;
} else {
$this->_href = Url::ensureHttp($href);
}
Expand Down
18 changes: 18 additions & 0 deletions tests/core/web/ExternalLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@ public function testSchemaHttpMissing()

$this->assertContains('public_html/go/there?p=1', $link->href);
}

public function testTarget()
{
$link = new WebsiteLink(['href' => 'https://luya.io', 'target' => '_blank']);

$this->assertSame('_blank', $link->getTarget());
}

public function testAnchorLink()
{
$link = new WebsiteLink(['href' => '#my-super-anchor']);

$this->assertSame('#my-super-anchor', $link->getHref());

$link = new WebsiteLink(['href' => '//page-link#my-super-anchor']);

$this->assertContains('/page-link#my-super-anchor', $link->getHref());
}
}