Skip to content

Commit

Permalink
fixed #398
Browse files Browse the repository at this point in the history
  • Loading branch information
windka committed Jan 8, 2025
1 parent 1591117 commit d346c52
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

# [16.1.2] - 2025-01-08
### webhook url parsing improved - [#398](https://github.com/windkh/node-red-contrib-telegrambot/issues/398)

# [16.1.1] - 2024-09-29
### IP address family any is 0 now - [#343](https://github.com/windkh/node-red-contrib-telegrambot/issues/343)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-telegrambot",
"version": "16.1.1",
"version": "16.1.2",
"description": "Telegram bot nodes for Node-RED",
"dependencies": {
"bluebird": "^3.7.2",
Expand Down
4 changes: 2 additions & 2 deletions telegrambot/99-telegrambot.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
bothost: { value: "", required: false },
botpath: { value: "", required: false },
localbotport: { value: 8443, required: false, validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }},
publicbotport: { value: 8443, required: false, validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }},
publicbotport: { value: 8443, required: false, validate:function(v) { return ((v === "") || (RED.validators.number(v) && ((v == 80) || (v == 88) || (v == 443) || (v == 8443)))) }},

// only for webhook and certificate
privatekey: { value: "", required: false },
Expand Down Expand Up @@ -204,7 +204,7 @@
<input type="checkbox" id="node-config-input-sslterminated" style="display: inline-block; width: auto; vertical-align: top;">
</div>

<div class="form-tips" style="width: auto"><b>Tip:</b> Webhook mode requires a HTTPS certificate. The certificate can also be a self-signed (=custom) one. If any of the host, key, certificate properties is left blank the bot will default to send only mode. If SSL termination is already handled by reverse proxy, key and certificate is not required.</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> Webhook mode requires a HTTPS certificate. The certificate can also be a self-signed (=custom) one. If any of the host, key, certificate properties is left blank the bot will default to send only mode. If SSL termination is already handled by reverse proxy, key and certificate is not required. Port must be one of 80, 88, 443, 8443.</div>
</div>
</div>

Expand Down
26 changes: 22 additions & 4 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,29 @@ module.exports = function (RED) {
// });
});

let botUrl = 'https://' + this.botHost + ':' + this.publicBotPort + '/';
if (this.botPath !== '') {
botUrl += this.botPath + '/';
const protocol = 'https://';
let tempUrl = this.botHost;
if(!tempUrl.startsWith(protocol)){

Check failure on line 328 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `(!tempUrl.startsWith(protocol))` with `·(!tempUrl.startsWith(protocol))·`

Check failure on line 328 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `(!tempUrl.startsWith(protocol))` with `·(!tempUrl.startsWith(protocol))·`
tempUrl = protocol + tempUrl;

Check failure on line 329 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `·`

Check failure on line 329 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `·`
}
botUrl += this.token;
const parsed = new URL(tempUrl);

if(parsed.port == ''){

Check failure on line 333 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `(parsed.port·==·'')` with `·(parsed.port·==·'')·`

Check failure on line 333 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `(parsed.port·==·'')` with `·(parsed.port·==·'')·`
parsed.port = this.publicBotPort;
}
parsed.port = 80;

if(parsed.pathname == ''){

Check failure on line 338 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `(parsed.pathname·==·'')` with `·(parsed.pathname·==·'')·`

Check failure on line 338 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `(parsed.pathname·==·'')` with `·(parsed.pathname·==·'')·`
parsed.pathname = this.botPath;
}

Check failure on line 340 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `·␍⏎···········`

Check failure on line 340 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `·␍⏎···········`
else {
if(parsed.botPath != ''){

Check failure on line 342 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `(parsed.botPath·!=·'')` with `·(parsed.botPath·!=·'')·`

Check failure on line 342 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `(parsed.botPath·!=·'')` with `·(parsed.botPath·!=·'')·`
parsed.pathname = parsed.pathname + '/' + this.botPath;

Check failure on line 343 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `·'/'·+·this.botPath;····` with `'/'·+·this.botPath;`

Check failure on line 343 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·'/'·+·this.botPath;····` with `'/'·+·this.botPath;`
}

Check failure on line 344 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `·`

Check failure on line 344 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `·`
}

Check failure on line 346 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `············`

Check failure on line 346 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `············`
let botUrl = parsed.href;
botUrl += '/' + this.token;

Check failure on line 348 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `·`

Check failure on line 348 in telegrambot/99-telegrambot.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Delete `·`

let setWebHookOptions;
if (!this.sslTerminated && this.useSelfSignedCertificate) {
Expand Down

0 comments on commit d346c52

Please sign in to comment.