public class SVGUriDetector extends Object
SVG images arrive in a lot of shapes: as a linked .svg file, as a
base 64 encoded data URI and as a plain (percent encoded) data URI, the latter being
the form typically used for small inline images in CSS.
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isSvgDataUri(String uri)
Returns true if the URI is a data URI carrying an SVG image, no matter whether
the content is base 64 encoded or percent encoded.
|
static boolean |
isSvgUri(String uri)
Returns true if the URI names an SVG image, either by media type (data URIs)
or by file extension.
|
static boolean |
looksLikeSvgContent(byte[] content)
Returns true if the content looks like an SVG document.
|
public static boolean isSvgDataUri(String uri)
public static boolean isSvgUri(String uri)
logo.svg?v=2 is recognized too.public static boolean looksLikeSvgContent(byte[] content)
Only XML that actually contains an svg element near the start is
accepted, so this can not mistake a raster image for an SVG: those never start
with a <.
Copyright © 2004–2026. All rights reserved.