Package ca.uhn.fhir.util
Class UrlUtil
java.lang.Object
ca.uhn.fhir.util.UrlUtil
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconstructAbsoluteUrl(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 StringconstructRelativeUrl(String theParentExtensionUrl, String theExtensionUrl)static StringescapeUrlParam(String theUnescaped)URL encode a value according to RFC 3986escapeUrlParams(Collection<String> theUnescaped)Applies the same encodong asescapeUrlParam(String)but against all values in a collectionstatic booleanisAbsolute(String theValue)static booleanisNeedsSanitization(CharSequence theString)static booleanstatic StringnormalizeCanonicalUrlForComparison(String theUrl)Normalizes canonical URLs for comparison.parseQueryString(String theQueryString)parseQueryStrings(String... theQueryString)static UrlUtil.UrlPartsParse a URL in one of the following forms: [Resource Type]?[Search Params] [Resource Type]/[Resource ID] [Resource Type]/[Resource ID]/_history/[Version ID]static RuntimeResourceDefinitionparseUrlResourceType(FhirContext theCtx, String theUrl)static StringsanitizeUrlPart(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 StringsanitizeUrlPart(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
-
Constructor Details
-
UrlUtil
public UrlUtil()
-
-
Method Details
-
constructAbsoluteUrl
Resolve a relative URL - THIS METHOD WILL NOT FAIL but will log a warning and return theEndpoint if the input is invalid. -
constructRelativeUrl
-
escapeUrlParam
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
Applies the same encodong asescapeUrlParam(String)but against all values in a collection -
isAbsolute
-
isNeedsSanitization
-
isValid
-
parseUrlResourceType
public static RuntimeResourceDefinition parseUrlResourceType(FhirContext theCtx, String theUrl) throws DataFormatException- Throws:
DataFormatException
-
parseQueryString
-
parseQueryStrings
-
normalizeCanonicalUrlForComparison
Normalizes canonical URLs for comparison. Trailing "/" is stripped, and any version identifiers or fragment hash is removed -
parseUrl
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
This method specifically HTML-encodes the " and < characters in order to prevent injection attacks -
sanitizeUrlPart
This method specifically HTML-encodes the " and < characters in order to prevent injection attacks.The following characters are escaped:
- '
- "
- <
- >
- \n (newline)
-
sanitizeUrlPart
Applies the same logic assanitizeUrlPart(CharSequence)but against an array, returning an array with the same strings as the input but with sanitization applied -
unescape
-
translateMatchUrl
-