diff --git a/svr.js b/svr.js index 2c322f0..c3b8607 100644 --- a/svr.js +++ b/svr.js @@ -14,7 +14,7 @@ /* * MIT License * - * Copyright (c) 2018-2023 SVR.JS Authors + * Copyright (c) 2018-2024 SVR.JS * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * @@ -556,7 +556,7 @@ function checkForEnabledDirectoryListing(hostname) { return true; } else if (hostname && hostnameM.indexOf("*.") == 0 && hostnameM != "*.") { var hostnamesRoot = hostnameM.substr(2); - if (hostname == hostnamesRoot || hostname.indexOf("." + hostnamesRoot) == hostname.length - hostnamesRoot.length - 1) { + if (hostname == hostnamesRoot || (hostname.length > hostnamesRoot.length && hostname.indexOf("." + hostnamesRoot) == hostname.length - hostnamesRoot.length - 1)) { return true; } } else if (hostname && hostname == hostnameM) { @@ -2778,7 +2778,7 @@ if (!cluster.isPrimary) { return true; } else if (req.headers.host && hostname.indexOf("*.") == 0 && hostname != "*.") { var hostnamesRoot = hostname.substr(2); - if (req.headers.host == hostnamesRoot || req.headers.host.indexOf("." + hostnamesRoot) == req.headers.host.length - hostnamesRoot.length - 1) { + if (req.headers.host == hostnamesRoot || (req.headers.host.length > hostnamesRoot.length && req.headers.host.indexOf("." + hostnamesRoot) == req.headers.host.length - hostnamesRoot.length - 1)) { return true; } } else if (req.headers.host && req.headers.host == hostname) {