fix search index out of bounds error (#548)
Co-authored-by: spencerwooo <spencer.woo@outlook.com>
This commit is contained in:
parent
0397fcd52f
commit
f7732101e8
1 changed files with 7 additions and 5 deletions
|
@ -27,13 +27,15 @@ import siteConfig from '../config/site.config'
|
|||
function mapAbsolutePath(path: string): string {
|
||||
// path is in the format of '/drive/root:/path/to/file', if baseDirectory is '/' then we split on 'root:',
|
||||
// otherwise we split on the user defined 'baseDirectory'
|
||||
const absolutePath = path.split(siteConfig.baseDirectory === '/' ? 'root:' : siteConfig.baseDirectory)[1]
|
||||
const absolutePath = path.split(siteConfig.baseDirectory === '/' ? 'root:' : siteConfig.baseDirectory)
|
||||
// path returned by the API may contain #, by doing a decodeURIComponent and then encodeURIComponent we can
|
||||
// replace URL sensitive characters such as the # with %23
|
||||
return absolutePath
|
||||
.split('/')
|
||||
.map(p => encodeURIComponent(decodeURIComponent(p)))
|
||||
.join('/')
|
||||
return absolutePath.length > 1 // solve https://github.com/spencerwooo/onedrive-vercel-index/issues/539
|
||||
? absolutePath[1]
|
||||
.split('/')
|
||||
.map(p => encodeURIComponent(decodeURIComponent(p)))
|
||||
.join('/')
|
||||
: ''
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue