Skip to content

Commit 93accd7

Browse files
authored
Update worker.js
1 parent 1baad5d commit 93accd7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

worker.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,18 @@ function apiUrl (methodName, params = null) {
181181
}
182182
return `https://api.telegram.org/bot${TOKEN}/${methodName}${query}`
183183
}
184+
185+
/*
186+
* https://stackoverflow.com/a/65672697
187+
*/
188+
async function urlExists(url) {
189+
return new Promise((resolve, reject) => {
190+
fetch(url, {
191+
method: "HEAD"
192+
}).then(response => {
193+
resolve(response.status.toString()[0] === "2")
194+
}).catch(error => {
195+
reject(false)
196+
})
197+
})
198+
}

0 commit comments

Comments
 (0)