Skip to content

Commit c0c061c

Browse files
committed
TRG-128: Ensure http_prefix is not duplicated when generating search result links.
1 parent 99537c2 commit c0c061c

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
@@ -151,8 +151,9 @@
151151
var content = s.processContent(result.content, query)
152152
output += '<li class="search-result">'
153153
output += '<h3 class="search-result__title">'
154-
var url = result.url.startsWith('/') ? result.url.slice(1) : result.url
155-
output += '<a href="' + pathToSiteRoot + url + '">'
154+
var pagePathWithoutLeadingSlash = result.url.startsWith('/') ? result.url.slice(1) : result.url
155+
var url = pathToSiteRoot.startsWith('.') ? pathToSiteRoot + pagePathWithoutLeadingSlash : '/' + pagePathWithoutLeadingSlash
156+
output += '<a href="' + url + '">'
156157
output += result.title
157158
output += '</a>'
158159
output += '</h3>'

0 commit comments

Comments
 (0)