Skip to content

Commit

Permalink
Merge pull request #15 from vvbbnn00/dev
Browse files Browse the repository at this point in the history
fix: Correct the bug where personal OneDrive cannot properly retrieve content when accessing the /api/item interface
  • Loading branch information
vvbbnn00 committed Mar 18, 2024
2 parents 86c689f + 897ccbe commit 6292dab
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 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
3 changes: 2 additions & 1 deletion app/src/pages/setup/step-1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export default function OAuthStep1({ installed, apiConfig, build_id }) {
const router = useRouter()
if (installed) {
router.query.path = router.pathname.substring(1).split('/')
return Folders(build_id)
//@ts-ignore
return Folders({ build_id })
}

return (
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/setup/step-2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default function OAuthStep2({ installed, redirectUri, oAuthUrl, build_id

if (installed) {
router.query.path = router.pathname.substring(1).split('/')
return Folders(build_id)
//@ts-ignore
return Folders({ build_id })
}

return (
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/setup/step-3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export default function OAuthStep3({ accessToken, expiryTime, refreshToken, erro

if (installed) {
router.query.path = router.pathname.substring(1).split('/')
return Folders(build_id)
//@ts-ignore
return Folders({ build_id })
}

const sendAuthTokensToServer = async () => {
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 6292dab

Please sign in to comment.