Skip to content

Commit

Permalink
fix: Correct the bug where personal OneDrive cannot properly retrieve…
Browse files Browse the repository at this point in the history
… content when accessing the /api/item interface
  • Loading branch information
vvbbnn00 committed Mar 18, 2024
1 parent 5d2f11b commit 897ccbe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/pages/api/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
try {
queryId = decryptData(id);
// console.log(queryId);
assert(queryId.match(/^[A-Za-z0-9]+$/))
assert(queryId.match(/^[A-Za-z0-9!]+$/))
} catch (err) {
res.status(400).json({error: 'Invalid driveItem ID.'})
return;
Expand Down
1 change: 1 addition & 0 deletions app/src/pages/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
delete item?.parentReference?.driveId
delete item?.parentReference?.driveType
delete item?.parentReference?.siteId
delete item?.parentReference?.path
item.id = encryptData(item.id);
if (item.parentReference.id) {
item.parentReference.id = encryptData(item?.parentReference?.id)
Expand Down
10 changes: 7 additions & 3 deletions app/src/utils/getFileIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const icons: { [key: string]: [IconPrefix, IconName] } = {
file: ['far', 'file'],
markdown: ['fab', 'markdown'],
book: ['fas', 'book'],
link: ['fas', 'link'],
link: ['fas', 'link']
}

const extensions = {
Expand Down Expand Up @@ -92,7 +92,7 @@ const extensions = {
mobi: icons.book,
azw3: icons.book,

url: icons.link,
url: icons.link
}

/**
Expand All @@ -109,9 +109,13 @@ export function hasKey(obj: Record<string, any>, key: string): boolean {
return key in obj
}

export function getRawExtension(fileName: string): string {
export function getRawExtension(fileName: string | undefined): string {
if (typeof fileName !== 'string') {
return ''
}
return fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2)
}

export function getExtension(fileName: string): string {
return getRawExtension(fileName).toLowerCase()
}
Expand Down

0 comments on commit 897ccbe

Please sign in to comment.