Groovy Documentation

org.grails.plugin.resource
[Java] Class URLUtils

java.lang.Object
  org.grails.plugin.resource.URLUtils

class URLUtils

Authors:
Marc Palmer (marc@grailsrocks.com)


Field Summary
private static int MAX_NORMALIZE_ITERATIONS

static java.util.regex.Pattern externalURLPattern

private static java.util.regex.Pattern invalidUriPartsPattern

 
Constructor Summary
URLUtils()

 
Method Summary
private static java.lang.String doDecodeUri(java.lang.String uri, java.lang.String originalUri)

private static java.lang.String doNormalizeUri(java.lang.String uri)

static java.lang.Boolean isExternalURL(java.lang.String url)

static java.lang.Boolean isRelativeURL(java.lang.String url)

Works out if url is relative, such that it would need to be corrected if the file containing the url is moved

static java.lang.String normalizeUri(java.lang.String uri)

Normalizes and decodes uri once.

static java.lang.String relativeURI(java.lang.String base, java.lang.String target)

Take a base URI and a target URI and resolve target against the base using the normal rules e.g. "..

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

MAX_NORMALIZE_ITERATIONS

private static final int MAX_NORMALIZE_ITERATIONS


externalURLPattern

public static java.util.regex.Pattern externalURLPattern


invalidUriPartsPattern

private static java.util.regex.Pattern invalidUriPartsPattern


 
Constructor Detail

URLUtils

URLUtils()


 
Method Detail

doDecodeUri

private static java.lang.String doDecodeUri(java.lang.String uri, java.lang.String originalUri)


doNormalizeUri

private static java.lang.String doNormalizeUri(java.lang.String uri)


isExternalURL

public static java.lang.Boolean isExternalURL(java.lang.String url)


isRelativeURL

public static java.lang.Boolean isRelativeURL(java.lang.String url)
Works out if url is relative, such that it would need to be corrected if the file containing the url is moved


normalizeUri

public static java.lang.String normalizeUri(java.lang.String uri)
Normalizes and decodes uri once. Check if result contains \ , /../ , /./ or // after decoding and throws IllegalArgumentException in that case
Parameters:
uri
Returns:


relativeURI

public static java.lang.String relativeURI(java.lang.String base, java.lang.String target)
Take a base URI and a target URI and resolve target against the base using the normal rules e.g. "../x", "./x" "x" results in a link relative to the base's folder and / is app-absolute, and anything with a protocol // is absolute Please note, I take full responsibility for the nastiness of this code. I could not find a nice way to do this, and I wanted to find an existing lib to do it. Its certainly not my finest moment. Sorry. Rely on the MenuTagTests. It's quite ugly in there.
throws:
URISyntaxException


 

Groovy Documentation