@@ -1097,7 +1097,7 @@ class RoaringBitmapBits {
1097
1097
1098
1098
1099
1099
class DocSearch {
1100
- constructor ( rawSearchIndex ) {
1100
+ constructor ( rawSearchIndex , rootPath ) {
1101
1101
/**
1102
1102
* @type {Map<String, RoaringBitmap> }
1103
1103
*/
@@ -1118,6 +1118,7 @@ class DocSearch {
1118
1118
*/
1119
1119
this . typeNameIdMap = new Map ( ) ;
1120
1120
this . ALIASES = new Map ( ) ;
1121
+ this . rootPath = rootPath ;
1121
1122
1122
1123
/**
1123
1124
* Special type name IDs for searching by array.
@@ -1971,7 +1972,7 @@ class DocSearch {
1971
1972
} ;
1972
1973
}
1973
1974
1974
- function buildHrefAndPath ( item ) {
1975
+ const buildHrefAndPath = item => {
1975
1976
let displayPath ;
1976
1977
let href ;
1977
1978
const type = itemTypes [ item . ty ] ;
@@ -1981,18 +1982,18 @@ class DocSearch {
1981
1982
1982
1983
if ( type === "mod" ) {
1983
1984
displayPath = path + "::" ;
1984
- href = ROOT_PATH + path . replace ( / : : / g, "/" ) + "/" +
1985
+ href = this . rootPath + path . replace ( / : : / g, "/" ) + "/" +
1985
1986
name + "/index.html" ;
1986
1987
} else if ( type === "import" ) {
1987
1988
displayPath = item . path + "::" ;
1988
- href = ROOT_PATH + item . path . replace ( / : : / g, "/" ) + "/index.html#reexport." + name ;
1989
+ href = this . rootPath + item . path . replace ( / : : / g, "/" ) + "/index.html#reexport." + name ;
1989
1990
} else if ( type === "primitive" || type === "keyword" ) {
1990
1991
displayPath = "" ;
1991
- href = ROOT_PATH + path . replace ( / : : / g, "/" ) +
1992
+ href = this . rootPath + path . replace ( / : : / g, "/" ) +
1992
1993
"/" + type + "." + name + ".html" ;
1993
1994
} else if ( type === "externcrate" ) {
1994
1995
displayPath = "" ;
1995
- href = ROOT_PATH + name + "/index.html" ;
1996
+ href = this . rootPath + name + "/index.html" ;
1996
1997
} else if ( item . parent !== undefined ) {
1997
1998
const myparent = item . parent ;
1998
1999
let anchor = type + "." + name ;
@@ -2019,13 +2020,13 @@ class DocSearch {
2019
2020
if ( item . implDisambiguator !== null ) {
2020
2021
anchor = item . implDisambiguator + "/" + anchor ;
2021
2022
}
2022
- href = ROOT_PATH + path . replace ( / : : / g, "/" ) +
2023
+ href = this . rootPath + path . replace ( / : : / g, "/" ) +
2023
2024
"/" + pageType +
2024
2025
"." + pageName +
2025
2026
".html#" + anchor ;
2026
2027
} else {
2027
2028
displayPath = item . path + "::" ;
2028
- href = ROOT_PATH + item . path . replace ( / : : / g, "/" ) +
2029
+ href = this . rootPath + item . path . replace ( / : : / g, "/" ) +
2029
2030
"/" + type + "." + name + ".html" ;
2030
2031
}
2031
2032
return [ displayPath , href , `${ exactPath } ::${ name } ` ] ;
@@ -3901,9 +3902,9 @@ function updateCrate(ev) {
3901
3902
function initSearch ( searchIndx ) {
3902
3903
rawSearchIndex = searchIndx ;
3903
3904
if ( typeof window !== "undefined" ) {
3904
- docSearch = new DocSearch ( rawSearchIndex ) ;
3905
+ docSearch = new DocSearch ( rawSearchIndex , ROOT_PATH ) ;
3905
3906
} else if ( typeof exports !== "undefined" ) {
3906
- docSearch = new DocSearch ( rawSearchIndex ) ;
3907
+ docSearch = new DocSearch ( rawSearchIndex , ROOT_PATH ) ;
3907
3908
exports . docSearch = docSearch ;
3908
3909
exports . parseQuery = DocSearch . parseQuery ;
3909
3910
}
0 commit comments