File tree 3 files changed +6
-14
lines changed
3 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -178,16 +178,20 @@ onclick = (event) ->
178
178
link = $ .eventTarget (event)
179
179
link = link .parentNode while link and link .tagName isnt ' A'
180
180
181
- if link and not link .target and isSameOrigin (link .href )
181
+ if link and not link .target and isSameOrigin (link .href ) and not isSameOriginDifferentDoc
182
182
event .preventDefault ()
183
183
path = link .pathname + link .search + link .hash
184
184
path = path .replace / ^ \/\/ + / , ' /' # IE11 bug
185
185
page .show (path)
186
+
186
187
return
187
188
188
189
isSameOrigin = (url ) ->
189
190
url .indexOf (" #{ location .protocol } //#{ location .hostname } " ) is 0
190
191
192
+ isSameOriginDifferentDoc = (url ) ->
193
+ url .pathname == location .pathname
194
+
191
195
updateCanonicalLink = ->
192
196
@canonicalLink ||= document .head .querySelector (' link[rel="canonical"]' )
193
197
@canonicalLink .setAttribute (' href' , " https://#{ location .host }#{ location .pathname } " )
Original file line number Diff line number Diff line change @@ -96,15 +96,5 @@ def clean_path(path)
96
96
path = path . gsub %r{\+ } , '_plus_'
97
97
path
98
98
end
99
-
100
- def path_to_root
101
- if subpath == ''
102
- return '../'
103
- else
104
- previous_dirs = subpath . scan ( /\/ / )
105
- return '../' * previous_dirs . length
106
- end
107
- end
108
-
109
99
end
110
100
end
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ class ExternalUrlsFilter < Filter
6
6
def call
7
7
if context [ :external_urls ]
8
8
9
- root = path_to_root
10
-
11
9
css ( 'a' ) . each do |node |
12
10
13
11
next unless anchorUrl = node [ 'href' ]
@@ -24,7 +22,7 @@ def call
24
22
25
23
context [ :external_urls ] . each do |host , name |
26
24
if url . host . to_s . match? ( host )
27
- node [ 'href' ] = root + name + url . path . to_s + '#' + url . fragment . to_s
25
+ node [ 'href' ] = '/' + name + url . path . to_s + '#' + url . fragment . to_s
28
26
end
29
27
end
30
28
You can’t perform that action at this time.
0 commit comments