Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

Commit f773210

Browse files
fix search index out of bounds error (#548)
Co-authored-by: spencerwooo <spencer.woo@outlook.com>
1 parent 0397fcd commit f773210

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

components/SearchModal.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ import siteConfig from '../config/site.config'
2727
function mapAbsolutePath(path: string): string {
2828
// path is in the format of '/drive/root:/path/to/file', if baseDirectory is '/' then we split on 'root:',
2929
// otherwise we split on the user defined 'baseDirectory'
30-
const absolutePath = path.split(siteConfig.baseDirectory === '/' ? 'root:' : siteConfig.baseDirectory)[1]
30+
const absolutePath = path.split(siteConfig.baseDirectory === '/' ? 'root:' : siteConfig.baseDirectory)
3131
// path returned by the API may contain #, by doing a decodeURIComponent and then encodeURIComponent we can
3232
// replace URL sensitive characters such as the # with %23
33-
return absolutePath
34-
.split('/')
35-
.map(p => encodeURIComponent(decodeURIComponent(p)))
36-
.join('/')
33+
return absolutePath.length > 1 // solve https://github.com/spencerwooo/onedrive-vercel-index/issues/539
34+
? absolutePath[1]
35+
.split('/')
36+
.map(p => encodeURIComponent(decodeURIComponent(p)))
37+
.join('/')
38+
: ''
3739
}
3840

3941
/**

0 commit comments

Comments
 (0)