File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
docusaurus-search-local/src/client/theme/SearchBar Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,19 @@ export async function legacyFetchIndexes(
3838 searchContext : string
3939) : Promise < IndexesData > {
4040 if ( process . env . NODE_ENV === "production" ) {
41+ const url = `${ baseUrl } ${ searchIndexUrl . replace (
42+ "{dir}" ,
43+ searchContext ? `-${ searchContext . replace ( / \/ / g, "-" ) } ` : ""
44+ ) } `;
45+
46+ // Catch potential attacks.
47+ const fullUrl = new URL ( url , location . origin ) ;
48+ if ( fullUrl . origin !== location . origin ) {
49+ throw new Error ( "Unexpected version url" ) ;
50+ }
51+
4152 const json = ( await (
42- await fetch (
43- `${ baseUrl } ${ searchIndexUrl . replace (
44- "{dir}" ,
45- searchContext ? `-${ searchContext . replace ( / \/ / g, "-" ) } ` : ""
46- ) } `
47- )
53+ await fetch ( url )
4854 ) . json ( ) ) as SerializedIndex [ ] ;
4955
5056 const wrappedIndexes : WrappedIndex [ ] = json . map (
You can’t perform that action at this time.
0 commit comments