Avoid escaping relative links in Markdown twice (!7940)
This commit is contained in:
parent
7a9ba9bb85
commit
17e3d3fde8
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Avoid escaping relative links in Markdown twice
|
||||||
|
merge_request: 7940
|
||||||
|
author: winniehell
|
|
@ -46,7 +46,7 @@ module Banzai
|
||||||
end
|
end
|
||||||
|
|
||||||
def rebuild_relative_uri(uri)
|
def rebuild_relative_uri(uri)
|
||||||
file_path = relative_file_path(uri.path)
|
file_path = relative_file_path(uri)
|
||||||
|
|
||||||
uri.path = [
|
uri.path = [
|
||||||
relative_url_root,
|
relative_url_root,
|
||||||
|
@ -59,8 +59,10 @@ module Banzai
|
||||||
uri
|
uri
|
||||||
end
|
end
|
||||||
|
|
||||||
def relative_file_path(path)
|
def relative_file_path(uri)
|
||||||
nested_path = build_relative_path(path, context[:requested_path])
|
path = Addressable::URI.unescape(uri.path)
|
||||||
|
request_path = Addressable::URI.unescape(context[:requested_path])
|
||||||
|
nested_path = build_relative_path(path, request_path)
|
||||||
file_exists?(nested_path) ? nested_path : path
|
file_exists?(nested_path) ? nested_path : path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -108,11 +110,7 @@ module Banzai
|
||||||
end
|
end
|
||||||
|
|
||||||
def uri_type(path)
|
def uri_type(path)
|
||||||
@uri_types[path] ||= begin
|
@uri_types[path] ||= current_commit.uri_type(path)
|
||||||
unescaped_path = Addressable::URI.unescape(path)
|
|
||||||
|
|
||||||
current_commit.uri_type(unescaped_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_commit
|
def current_commit
|
||||||
|
|
Loading…
Reference in New Issue