diff --git a/CHANGELOG.md b/CHANGELOG.md index 72f9522..908382f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Added: 1. Add health-check endpoint (by @mironov) * `options.webHook.healthEndpoint` +1. Use *String#indexOf()*, instead of *RegExp#test()*, to + find token in webhook request (by @AVVS) * * * diff --git a/src/telegramWebHook.js b/src/telegramWebHook.js index d4db943..b8f29f9 100644 --- a/src/telegramWebHook.js +++ b/src/telegramWebHook.js @@ -30,7 +30,6 @@ class TelegramBotWebHook { this.options.https = options.https || {}; this.options.healthEndpoint = options.healthEndpoint || '/healthz'; this.callback = callback; - this._regex = new RegExp(this.token); this._healthRegex = new RegExp(this.options.healthEndpoint); this._webServer = null; this._open = false; @@ -138,7 +137,7 @@ class TelegramBotWebHook { debug('WebHook request URL: %s', req.url); debug('WebHook request headers: %j', req.headers); - if (this._regex.test(req.url)) { + if (req.url.indexOf(this.token) !== -1) { if (req.method !== 'POST') { debug('WebHook request isn\'t a POST'); res.statusCode = 418; // I'm a teabot!