Permalink
Browse files

Fix bug and unit test for ExtractDomain; resolves #277 (#278)

  • Loading branch information...
borislin authored and ruebot committed Oct 17, 2018
1 parent 7c3a80d commit 2c66b093a7febea621423a1b9bec1e4d00bfa832
@@ -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

Please sign in to comment.