public static boolean isDirectory(URL resourceURL) throws URISyntaxException {
        final String protocol = resourceURL.getProtocol();
        switch (protocol) {
            case "jar":
                try {
                    final JarURLConnection jarConnection = (JarURLConnection) resourceURL.openConnection();
                    final JarEntry entry = jarConnection.getJarEntry();
                    if (entry.isDirectory()) {
                        return true;
                    }

                    // WARNING! Heuristics ahead.
                    // It turns out that JarEntry#isDirectory() really just tests whether the filename ends in a '/'.
                    // If you try to open the same URL without a trailing '/', it'll succeed — but the result won't be
                    // what you want. We try to get around this by calling getInputStream() on the file inside the jar.
                    // This seems to return null for directories (though that behavior is undocumented as far as I
                    // can tell). If you have a better idea, please improve this.

                    final String relativeFilePath = entry.getName();
                    final JarFile jarFile = jarConnection.getJarFile();
                    final ZipEntry zipEntry = jarFile.getEntry(relativeFilePath);
                    final InputStream inputStream = jarFile.getInputStream(zipEntry);

                    return inputStream == null;
                } catch (IOException e) {
                    throw new ResourceNotFoundException(e);
                }
            case "file":
                return new File(resourceURL.toURI()).isDirectory();
            default:
                throw new IllegalArgumentException("Unsupported protocol " + resourceURL.getProtocol() +
                        " for resource " + resourceURL);
        }
    }
@Test
    void isDirectoryReturnsTrueForDirectoriesInJarsWithoutTrailingSlashes() throws Exception {
        final URL url = new URL("jar:" + resourceJar.toExternalForm() + "!/dir");

        assertThat(url.getProtocol()).isEqualTo("jar");
        assertThat(ResourceURL.isDirectory(url)).isTrue();
    }