
Package ca.uhn.fhir.util
Class UrlUtil
- java.lang.Object
-
- ca.uhn.fhir.util.UrlUtil
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UrlUtil.UrlParts
-
Constructor Summary
Constructors Constructor Description UrlUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
constructAbsoluteUrl(String theBase, String theEndpoint)
Resolve a relative URL - THIS METHOD WILL NOT FAIL but will log a warning and return theEndpoint if the input is invalid.static String
constructRelativeUrl(String theParentExtensionUrl, String theExtensionUrl)
static String
escapeUrlParam(String theUnescaped)
URL encode a value according to RFC 3986static List<String>
escapeUrlParams(Collection<String> theUnescaped)
Applies the same encodong asescapeUrlParam(String)
but against all values in a collectionstatic boolean
isAbsolute(String theValue)
static boolean
isNeedsSanitization(CharSequence theString)
static boolean
isValid(String theUrl)
static String
normalizeCanonicalUrlForComparison(String theUrl)
Normalizes canonical URLs for comparison.static Map<String,String[]>
parseQueryString(String theQueryString)
static Map<String,String[]>
parseQueryStrings(String... theQueryString)
static UrlUtil.UrlParts
parseUrl(String theUrl)
Parse a URL in one of the following forms: [Resource Type]?[Search Params] [Resource Type]/[Resource ID] [Resource Type]/[Resource ID]/_history/[Version ID]static RuntimeResourceDefinition
parseUrlResourceType(FhirContext theCtx, String theUrl)
static String
sanitizeUrlPart(CharSequence theString)
This method specifically HTML-encodes the " and < characters in order to prevent injection attacks.static String[]
sanitizeUrlPart(String[] theParameterValues)
Applies the same logic assanitizeUrlPart(CharSequence)
but against an array, returning an array with the same strings as the input but with sanitization appliedstatic String
sanitizeUrlPart(IPrimitiveType<?> theString)
This method specifically HTML-encodes the " and < characters in order to prevent injection attacksstatic List<org.apache.http.NameValuePair>
translateMatchUrl(String theMatchUrl)
static String
unescape(String theString)
-
-
-
Constructor Detail
-
UrlUtil
public UrlUtil()
-
-
Method Detail
-
constructAbsoluteUrl
public static String constructAbsoluteUrl(String theBase, String theEndpoint)
Resolve a relative URL - THIS METHOD WILL NOT FAIL but will log a warning and return theEndpoint if the input is invalid.
-
constructRelativeUrl
public static String constructRelativeUrl(String theParentExtensionUrl, String theExtensionUrl)
-
escapeUrlParam
public static String escapeUrlParam(String theUnescaped)
URL encode a value according to RFC 3986This method is intended to be applied to an individual parameter name or value. For example, if you are creating the URL
http://example.com/fhir/Patient?key=føø
it would be appropriate to pass the string "føø" to this method, but not appropriate to pass the entire URL since characters such as "/" and "?" would also be escaped.
-
escapeUrlParams
public static List<String> escapeUrlParams(@Nonnull Collection<String> theUnescaped)
Applies the same encodong asescapeUrlParam(String)
but against all values in a collection
-
isAbsolute
public static boolean isAbsolute(String theValue)
-
isNeedsSanitization
public static boolean isNeedsSanitization(CharSequence theString)
-
parseUrlResourceType
public static RuntimeResourceDefinition parseUrlResourceType(FhirContext theCtx, String theUrl) throws DataFormatException
- Throws:
DataFormatException
-
parseQueryString
public static Map<String,String[]> parseQueryString(String theQueryString)
-
parseQueryStrings
public static Map<String,String[]> parseQueryStrings(String... theQueryString)
-
normalizeCanonicalUrlForComparison
public static String normalizeCanonicalUrlForComparison(String theUrl)
Normalizes canonical URLs for comparison. Trailing "/" is stripped, and any version identifiers or fragment hash is removed
-
parseUrl
public static UrlUtil.UrlParts parseUrl(String theUrl)
Parse a URL in one of the following forms:- [Resource Type]?[Search Params]
- [Resource Type]/[Resource ID]
- [Resource Type]/[Resource ID]/_history/[Version ID]
-
sanitizeUrlPart
public static String sanitizeUrlPart(IPrimitiveType<?> theString)
This method specifically HTML-encodes the " and < characters in order to prevent injection attacks
-
sanitizeUrlPart
public static String sanitizeUrlPart(CharSequence theString)
This method specifically HTML-encodes the " and < characters in order to prevent injection attacks.The following characters are escaped:
- '
- "
- <
- >
- \n (newline)
-
sanitizeUrlPart
public static String[] sanitizeUrlPart(String[] theParameterValues)
Applies the same logic assanitizeUrlPart(CharSequence)
but against an array, returning an array with the same strings as the input but with sanitization applied
-
translateMatchUrl
public static List<org.apache.http.NameValuePair> translateMatchUrl(String theMatchUrl)
-
-