Skip to content

Commit

Permalink
Issue jetty#11040 Register custom URI scheme in PathResource when nec…
Browse files Browse the repository at this point in the history
…essary
  • Loading branch information
kohlschuetter committed Dec 11, 2023
1 parent bd342ac commit 22fcf72
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ public class PathResource extends Resource
{
private static final Logger LOG = LoggerFactory.getLogger(PathResource.class);

public static Index<String> SUPPORTED_SCHEMES = new Index.Builder<String>()
.caseSensitive(false)
.with("file")
.with("jrt")
.build();
public static Index<String> SUPPORTED_SCHEMES = initSupportedSchemes(null);

// The path object represented by this instance
private final Path path;
Expand Down Expand Up @@ -541,4 +537,18 @@ public String toString()
{
return this.uri.toASCIIString();
}

static Index<String> initSupportedSchemes(String extraScheme)
{
Index.Builder<String> builder = new Index.Builder<String>()
.caseSensitive(false)
.with("file")
.with("jrt");
if (extraScheme != null)
{
builder = builder.with(extraScheme);
}

return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class ResourceFactoryInternals
resourceFactory = url.toString().contains("!/") ? mountedPathResourceFactory : pathResourceFactory;
}

RESOURCE_FACTORIES.put(url.getProtocol(), resourceFactory);
String protocol = url.getProtocol();
PathResource.SUPPORTED_SCHEMES = PathResource.initSupportedSchemes(protocol);
RESOURCE_FACTORIES.put(protocol, resourceFactory);
}
}

Expand Down

0 comments on commit 22fcf72

Please sign in to comment.