object UrlUtils
Created by ryanm on 6/14/2017.
- Alphabetic
- By Inheritance
- UrlUtils
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getUrlPath(url: String, extraHostnames: List[String] = Nil): String
For any URL, returns the "path" component (including query params and anchor.)
For any URL, returns the "path" component (including query params and anchor.)
Meant to be used for possibly-malformed URLs with special characters (eg '{', '}') which would fail to be parsed by default URL/URI behavior.
- url
Any URL (absolute, relative, with/without scheme, etc.)
- extraHostnames
Keywords to treat as potential "hostnames" when parsing a URI without any transport scheme. These are in addition to
localhost
.- returns
The path component of the given URL.
- def getUrlWithSubdomain(url: String, subd: String): String
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def joinUrl(base: String, add: String*): String
Concatenate a series of strings that are treated as URL segments, adding
/
between each segment as needed, preserving the trailing slash in the final segment, as well as any leading slash in the first segment.Concatenate a series of strings that are treated as URL segments, adding
/
between each segment as needed, preserving the trailing slash in the final segment, as well as any leading slash in the first segment.This method assumes the
base
is some already-valid URL that has at least a protocol and a host, and so will treat each of the givenadd
segments as PATH segments where ensuring a/
between each segment is the right thing to do.One caveat of this is that if for some reason you need to have an empty path segment, leading to a URL like
https://example.com/foo//bar
(empty segment betweenfoo
andbar
), this method is not appropriate to use; e.g.joinUrl("https://example.com", "foo", "", "bar")
will output"https://example.com/foo/bar"
. Instead, you should use thejava.net.URL
constructor, or treat thefoo//bar
segments as a single segment, since this method will not attempt to modify the insides of any given segment (only the edges).Note that the semantics of this method differ from the
new URL(context: URL, spec: String)
constructor, as this method is not trying to resolve relative-vs-absolute paths. Ifspec
has a leading slash, the URL "context" constructor will replace the entire path with thatspec
, whereas this method will simply append thespec
as the next segment. This method also assumes that all of the segments have already been properly escaped; it will not interpret escape sequences or make any noise if an segment contains string data that would create an invalid URL.See the unit tests at
UrlUtilsSpec
for a suite of expected behaviors. - def lastHrefSegment(s: String): String
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()