Skip to content

Commit

Permalink
Update api-utils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored Jan 25, 2021
1 parent dfd2e57 commit d7bfae6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/next/next-server/server/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ export function tryGetPreviewData(
}
}

function isNotValidData (str: string): boolean {
return typeof str !== 'string' || str.length < 16
}

function setPreviewData<T>(
res: NextApiResponse<T>,
data: object | string, // TODO: strict runtime type checking
options: {
maxAge?: number
} & __ApiPreviewProps
): NextApiResponse<T> {
const isNotValidData = (str: string): boolean => {
return typeof str !== 'string' || str.length < 16
}

if (isNotValidData(options.previewModeId)) {
throw new Error('invariant: invalid previewModeId')
}
Expand Down

0 comments on commit d7bfae6

Please sign in to comment.