The URLUtil class is a static class with methods for working with full and relative URLs within Flex.
Static variables
staticfinalread onlySERVER_NAME_TOKEN:String = "{server.name}"
The pattern in the String that is passed to the replaceTokens()
method that
is replaced by the application's server name.
staticfinalread onlySERVER_PORT_TOKEN:String = "{server.port}"
The pattern in the String that is passed to the replaceTokens()
method that
is replaced by the application's port.
Static methods
staticgetFullURL(rootURL:String, url:String):String
Converts a potentially relative URL to a fully-qualified URL. If the URL is not relative, it is returned as is. If the URL starts with a slash, the host and port from the root URL are prepended. Otherwise, the host, port, and path are prepended.
Parameters:
rootURL | URL used to resolve the URL specified by the |
---|---|
url | URL to convert. |
Returns:
Fully-qualified URL.
staticgetPort(url:String):UInt
Returns the port number from the specified URL.
Parameters:
url | The URL to analyze. |
---|
Returns:
The port number of the specified URL.
staticgetProtocol(url:String):String
Returns the protocol section of the specified URL.
The following examples show what is returned based on different URLs:
getProtocol("https://localhost:2700/") returns "https"
getProtocol("rtmp://www.myCompany.com/myMainDirectory/groupChatApp/HelpDesk") returns "rtmp"
getProtocol("rtmpt:/sharedWhiteboardApp/June2002") returns "rtmpt"
getProtocol("rtmp::1234/chatApp/room_name") returns "rtmp"
Parameters:
url | String containing the URL to parse. |
---|
Returns:
The protocol or an empty String if no protocol is specified.
staticgetServerName(url:String):String
Returns the server name from the specified URL.
Parameters:
url | The URL to analyze. |
---|
Returns:
The server name of the specified URL.
staticgetServerNameWithPort(url:String):String
Returns the domain and port information from the specified URL.
Parameters:
url | The URL to analyze. |
---|
Returns:
The server name and port of the specified URL.
statichasTokens(url:String):Bool
Given a url, determines whether the url contains the server.name and server.port tokens.
Parameters:
url | A url string. |
---|
Returns:
true
if the url contains server.name and server.port tokens.
statichasUnresolvableTokens():Bool
If the LoaderConfig.url
property is not available, the replaceTokens()
method will not
replace the server name and port properties properly.
Returns:
true
if the LoaderConfig.url
property is not available. Otherwise, false
.
staticisHttpURL(url:String):Bool
Determines if the URL uses the HTTP, HTTPS, or RTMP protocol.
Parameters:
url | The URL to analyze. |
---|
Returns:
true
if the URL starts with "http://", "https://", or "rtmp://".
staticisHttpsURL(url:String):Bool
Determines if the URL uses the secure HTTPS protocol.
Parameters:
url | The URL to analyze. |
---|
Returns:
true
if the URL starts with "https://".
staticreplacePort(uri:String, newPort:UInt):String
Returns a new String with the port replaced with the specified port. If there is no port in the specified URI, the port is inserted. This method expects that a protocol has been specified within the URI.
Parameters:
uri | String containing the URI in which the port is replaced. |
---|---|
newPort | uint containing the new port to subsitute. |
Returns:
The URI with the new port.
staticreplaceProtocol(uri:String, newProtocol:String):String
Replaces the protocol of the specified URI with the given protocol.
Parameters:
uri | String containing the URI in which the protocol needs to be replaced. |
---|---|
newProtocol | String containing the new protocol to use. |
Returns:
The URI with the protocol replaced, or an empty String if the URI does not contain a protocol.
staticreplaceTokens(url:String):String
Returns a new String with the port and server tokens replaced with the port and server from the currently running application.
Parameters:
url | String containing the |
---|
Returns:
The URI with the port and server replaced.