Skip to content

Commit

Permalink
Fix calculating button absolute path length
Browse files Browse the repository at this point in the history
Fix calculating button absolute path length with non-Latin symbols according issue EdJoPaTo#183
  • Loading branch information
harimambura authored Jun 25, 2022
1 parent 9514b67 commit 30ea891
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ function renderRow(templates: readonly ButtonTemplate[], path: string): readonly

function renderCallbackButtonTemplate(template: CallbackButtonTemplate, path: string): InlineKeyboardButton {
const absolutePath = combinePath(path, template.relativePath)
if (absolutePath.length > 64) {
throw new Error(`callback_data only supports 1-64 bytes. With this button (${template.relativePath}) it would get too long (${absolutePath.length}). Full path: ${absolutePath}`)
const absolutePathLength = Buffer.byteLength(absolutePath, 'utf-8')
if (absolutePathLength > 64) {
throw new Error(`callback_data only supports 1-64 bytes. With this button (${template.relativePath}) it would get too long (${absolutePathLength}). Full path: ${absolutePath}`)
}

return {
Expand Down

0 comments on commit 30ea891

Please sign in to comment.