File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -308,7 +308,13 @@ function fillPopover(
308308 // All a.href attributes are always full absolute URLs, as a string.
309309 // We assume that the "product landing page" is the first
310310 // portion of all links.
311- productHeadLink . href = linkURL . pathname . split ( '/' ) . slice ( 0 , 3 ) . join ( '/' )
311+ const regex = / ^ \/ (?< lang > \w { 2 } \/ ) ? (?< version > [ \w - ] + @ [ \w - . ] + \/ ) ? (?< product > [ \w - ] + \/ ) ? /
312+ const match = regex . exec ( linkURL . pathname )
313+ if ( match ?. groups ) {
314+ const { lang, version, product } = match . groups
315+ const productURL = [ lang , version , product ] . map ( ( n ) => n || '' ) . join ( '' )
316+ productHeadLink . href = `${ linkURL . origin } /${ productURL } `
317+ }
312318 productHead . style . display = 'block'
313319 }
314320 } else {
You can’t perform that action at this time.
0 commit comments