Permalink
Browse files
Fix bug and unit test for ExtractDomain; resolves #277 (#278)
- Loading branch information...
|
@@ -27,16 +27,16 @@ object ExtractDomain { |
|
|
* @return domain host, source or null if url is null.
|
|
|
*/
|
|
|
def apply(url: String, source: String = ""): String = {
|
|
|
val maybeSource: Option[URL] = checkUrl(source)
|
|
|
val maybeHost: Option[URL] = checkUrl(url)
|
|
|
maybeSource match {
|
|
|
case Some(source) =>
|
|
|
source.getHost
|
|
|
val maybeSource: Option[URL] = checkUrl(source)
|
|
|
maybeHost match {
|
|
|
case Some(host) =>
|
|
|
host.getHost
|
|
|
|
|
|
case None =>
|
|
|
maybeHost match {
|
|
|
case Some(host) =>
|
|
|
host.getHost
|
|
|
maybeSource match {
|
|
|
case Some(source) =>
|
|
|
source.getHost
|
|
|
case None =>
|
|
|
""
|
|
|
}
|
|
|
|
@@ -34,7 +34,8 @@ class ExtractDomainTest extends FunSuite { |
|
|
|
|
|
private val data2 = Seq.newBuilder.+=(
|
|
|
(index, "http://www.umiacs.umd.edu/~jimmylin/", umiacs),
|
|
|
(index, "lintool/", "")).result()
|
|
|
("https://github.com/lintool", "http://www.umiacs.umd.edu/~jimmylin/", "github.com"),
|
|
|
(index, "https://github.com/lintool", "github.com")).result()
|
|
|
|
|
|
private val data3 = Seq.newBuilder.+=(
|
|
|
("http://www.seetorontonow.canada-booknow.com\\booking_results.php", "www.seetorontonow.canada-booknow.com")).result()
|
|
|
0 comments on commit
2c66b09