]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
added more strict checking of http method to Ping service
authorIsaac Suttell <isaac@isaacsuttell.com>
Fri, 12 Aug 2022 22:45:54 +0000 (15:45 -0700)
committerBastien Wirtz <bastien.wirtz@gmail.com>
Sat, 8 Oct 2022 09:53:26 +0000 (11:53 +0200)
src/components/services/Ping.vue

index 9f4a03de337ee0738fec767629b3d4ee4a3a8710..571c5adbdd392d3799d09fc58b549021e9f3b731 100644 (file)
@@ -29,7 +29,13 @@ export default {
   },
   methods: {
     fetchStatus: async function () {
-      const method = typeof this.item.method === 'string' && this.item.method.toLowerCase() === "get" ? "GET" : "HEAD"
+      const method = typeof this.item.method === 'string' ? this.item.method.toUpperCase() : 'unknown';
+
+      if (!['GET', 'HEAD', 'OPTION'].includes(method)) {
+        console.error(`Ping: ${method} is not a supported HTTP method`);
+        return;
+      }
+
       this.fetch("/", { method, cache: "no-cache" }, false)
         .then(() => {
           this.status = "online";