mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
fix search index out of bounds error (#548)
Co-authored-by: spencerwooo <spencer.woo@outlook.com>
This commit is contained in:
@@ -27,13 +27,15 @@ import siteConfig from '../config/site.config'
|
|||||||
function mapAbsolutePath(path: string): string {
|
function mapAbsolutePath(path: string): string {
|
||||||
// path is in the format of '/drive/root:/path/to/file', if baseDirectory is '/' then we split on 'root:',
|
// 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'
|
// 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
|
// 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
|
// replace URL sensitive characters such as the # with %23
|
||||||
return absolutePath
|
return absolutePath.length > 1 // solve https://github.com/spencerwooo/onedrive-vercel-index/issues/539
|
||||||
|
? absolutePath[1]
|
||||||
.split('/')
|
.split('/')
|
||||||
.map(p => encodeURIComponent(decodeURIComponent(p)))
|
.map(p => encodeURIComponent(decodeURIComponent(p)))
|
||||||
.join('/')
|
.join('/')
|
||||||
|
: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user