Skip to content

Commit f1a197d

Browse files
committed
Implemented Callback, fixed lint errors
1 parent 99e9458 commit f1a197d

File tree

12 files changed

+158
-169
lines changed

12 files changed

+158
-169
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 40 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Use your ntfy.sh (free selfhosted) server to send and receive push notifications
2121
Placeholder for the next version (at the beginning of the line):
2222
### **WORK IN PROGRESS**
2323
-->
24+
25+
### **WORK IN PROGRESS**
26+
* (sestriel) Implemented callback
27+
* (sestriel) linter cleanup
28+
2429
### 0.3.5 (2025-01-31)
2530
* (Scrounger) jsonConfig optimized
2631
* (Scrounger) encryption bug fix

admin/words.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actionButton.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33
class ActionButton
44
{
@@ -11,12 +11,12 @@ class ActionButton
1111

1212
isValidUrl(urlString)
1313
{
14-
const urlPattern = new RegExp('^(https?:\\/\\/)?'+ // validate protocol
15-
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // validate domain name
16-
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // validate OR ip (v4) address
17-
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // validate port and path
18-
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // validate query string
19-
'(\\#[-a-z\\d_]*)?$','i'); // validate fragment locator
14+
const urlPattern = new RegExp("^(https?:\\/\\/)?"+ // validate protocol
15+
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|"+ // validate domain name
16+
"((\\d{1,3}\\.){3}\\d{1,3}))"+ // validate OR ip (v4) address
17+
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*"+ // validate port and path
18+
"(\\?[;&a-z\\d%_.~+=-]*)?"+ // validate query string
19+
"(\\#[-a-z\\d_]*)?$","i"); // validate fragment locator
2020
return !!urlPattern.test(urlString);
2121
}
2222
}
@@ -25,7 +25,7 @@ class ActionButtonView extends ActionButton
2525
{
2626
constructor(label, url, clear = false)
2727
{
28-
super('view', label, clear);
28+
super("view", label, clear);
2929

3030
this.url = url;
3131
}
@@ -36,12 +36,12 @@ class ActionButtonHTTP extends ActionButton
3636
{
3737
constructor(label, url, clear = false)
3838
{
39-
super('http', label, clear);
39+
super("http", label, clear);
4040

4141
this.url = url;
42-
this.method = 'POST';
42+
this.method = "POST";
4343
this.headers = {};
44-
this.body = '';
44+
this.body = "";
4545
}
4646

4747
getData()

lib/message.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22

33

44
class Message {
@@ -8,13 +8,13 @@ class Message {
88
* @param { String } message
99
* @param { Number } priority
1010
*/
11-
constructor(topic, title = '', message = '', priority = 3) {
11+
constructor(topic, title = "", message = "", priority = 3) {
1212
this.topic = topic;
1313
this.title = title;
1414
this.message = message;
1515
this.priority = priority;
1616

17-
this.delay = '';
17+
this.delay = "";
1818
this.tags = [];
1919
this.clickURL = null;
2020
this.iconURL = null;
@@ -27,7 +27,7 @@ class Message {
2727
* @param { string | null } delay
2828
*/
2929
addDelay(delay) {
30-
if (delay !== null && delay !== '') this.delay = delay;
30+
if (delay !== null && delay !== "") this.delay = delay;
3131
}
3232

3333
/**
@@ -46,7 +46,7 @@ class Message {
4646
}
4747

4848
addClickURL(url) {
49-
if (url === null || url === '') return;
49+
if (url === null || url === "") return;
5050
if (!this.isValidUrl(url)) return;
5151
this.clickURL = url;
5252
}
@@ -57,12 +57,12 @@ class Message {
5757
}
5858

5959
addAttachment(attachFromURL, filename) {
60-
if (attachFromURL === null || attachFromURL === '') return;
60+
if (attachFromURL === null || attachFromURL === "") return;
6161
if (!this.isValidUrl(attachFromURL)) return;
6262

6363
this.attachment = {
6464
url: attachFromURL,
65-
filename: (filename !== null && filename !== '') ? filename : attachFromURL.substring(attachFromURL.lastIndexOf('/') + 1)
65+
filename: (filename !== null && filename !== "") ? filename : attachFromURL.substring(attachFromURL.lastIndexOf("/") + 1)
6666
};
6767
}
6868

@@ -71,24 +71,24 @@ class Message {
7171
}
7272

7373
isValidUrl(urlString) {
74-
const urlPattern = new RegExp('^(https?:\\/\\/)?' + // validate protocol
75-
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // validate domain name
76-
'((\\d{1,3}\\.){3}\\d{1,3}))' + // validate OR ip (v4) address
77-
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // validate port and path
78-
'(\\?[;&a-z\\d%_.~+=-]*)?' + // validate query string
79-
'(\\#[-a-z\\d_]*)?$', 'i'); // validate fragment locator
74+
const urlPattern = new RegExp("^(https?:\\/\\/)?" + // validate protocol
75+
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // validate domain name
76+
"((\\d{1,3}\\.){3}\\d{1,3}))" + // validate OR ip (v4) address
77+
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // validate port and path
78+
"(\\?[;&a-z\\d%_.~+=-]*)?" + // validate query string
79+
"(\\#[-a-z\\d_]*)?$", "i"); // validate fragment locator
8080
return !!urlPattern.test(urlString);
8181
}
8282

8383
toJSON() {
8484
return {
8585
topic: this.topic,
8686
priority: this.priority,
87-
...(this.title !== null && this.title !== '' && { title: this.title }),
88-
...(this.message !== null && this.message !== '' && { message: this.message }),
89-
...(this.iconURL !== null && this.iconURL !== '' && { icon: this.iconURL }),
90-
...(this.delay !== null && this.delay !== '' && { delay: this.delay }),
91-
...(this.clickURL !== null && this.clickURL !== '' && { click: this.clickURL }),
87+
...(this.title !== null && this.title !== "" && { title: this.title }),
88+
...(this.message !== null && this.message !== "" && { message: this.message }),
89+
...(this.iconURL !== null && this.iconURL !== "" && { icon: this.iconURL }),
90+
...(this.delay !== null && this.delay !== "" && { delay: this.delay }),
91+
...(this.clickURL !== null && this.clickURL !== "" && { click: this.clickURL }),
9292
...(this.attachment !== null && { attach: this.attachment.url, filename: this.attachment.filename }),
9393
...(this.tags.length > 0 && { tags: this.tags }),
9494
...(this.actionBtns.length > 0 && { actions: this.actionBtns }),

0 commit comments

Comments
 (0)