Skip to content

Commit babdeb7

Browse files
committed
TRG-128: Ensure http_prefix is not duplicated when generating search result links.
1 parent 7ccde80 commit babdeb7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/assets/javascripts/_modules/search.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@
153153
var content = s.processContent(result.content, query)
154154
output += '<li class="search-result">'
155155
output += '<h3 class="search-result__title">'
156-
var url = result.url.startsWith('/') ? result.url.slice(1) : result.url
157-
output += '<a href="' + pathToSiteRoot + url + '">'
156+
var pagePathWithoutLeadingSlash = result.url.startsWith('/') ? result.url.slice(1) : result.url
157+
var url = pathToSiteRoot.startsWith('.') ? pathToSiteRoot + pagePathWithoutLeadingSlash : '/' + pagePathWithoutLeadingSlash
158+
output += '<a href="' + url + '">'
158159
output += result.title
159160
output += '</a>'
160161
output += '</h3>'

0 commit comments

Comments
 (0)