Skip to content
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
13 changes: 0 additions & 13 deletions brigid/markdown_render/processors/external_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from markdown.inlinepatterns import LINK_RE as EXTERNAL_LINK_RE
from markdown.inlinepatterns import LinkInlineProcessor

from brigid.library.storage import storage
from brigid.markdown_render.context import render_context


Expand All @@ -23,22 +22,10 @@ def handleMatch(self, m, data): # noqa # pylint: disable=all

parsed_url = urlparse(href)

site = storage.get_site()

context = render_context.get()

parsed_site = urlparse(site.url)

# validate external links

# TODO: compare taking into account the default ports, aka example.com:90 = example.com
# TODO: is this required, link could be to the same domain but in different project
if parsed_site.netloc == parsed_url.netloc:
context.add_error(
failed_text=data, message="Use internal links syntax to specify links to the same domain"
)
return result

if parsed_url.scheme == "":
context.add_error(failed_text=data, message="Specify schema/protocol for external links")
return result
Expand Down
17 changes: 0 additions & 17 deletions brigid/markdown_render/processors/tests/test_external_links.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from brigid.library.storage import storage
from brigid.library.tests import make as library_make
from brigid.markdown_render.markdown_render import render_page

Expand Down Expand Up @@ -34,19 +33,3 @@ def test_no_schema(self) -> None:

assert len(result.errors) == 1
assert result.errors[0].message == "Specify schema/protocol for external links"

def test_used_for_internal_links(self) -> None:

site = storage.get_site()

text = f"""
[xxx]({site.url})
"""

article = library_make.article()
page = library_make.page(article, body=text)

result = render_page(page)

assert len(result.errors) == 1
assert result.errors[0].message == "Use internal links syntax to specify links to the same domain"
2 changes: 2 additions & 0 deletions changes/next_release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

- Removed too restrictive error on rendering external links. Now, external links can target the same domain as the current page.
2 changes: 0 additions & 2 deletions changes/unreleased.md

This file was deleted.