Skip to main content

Example

Printing URLs extracted with default options and an allowed URL:

import io.lambdaworks.detection.UrlDetector
import io.lemonlabs.uri.{Host, AbsoluteUrl}

val detector: UrlDetector = UrlDetector.default.withAllowed(Host.parse("lambdaworks.io"))
// detector: UrlDetector = io.lambdaworks.detection.UrlDetector@5fb2a84a
val extractedUrls: Set[AbsoluteUrl] = detector.extract("Hello! This is a URL - lambdaworks.io")
// extractedUrls: Set[AbsoluteUrl] = Set(
// AbsoluteUrl(
// scheme = "http",
// authority = Authority(
// userInfo = None,
// host = DomainName(value = "lambdaworks.io"),
// port = None
// ),
// path = ,
// query = QueryString(params = Vector()),
// fragment = None
// )
// )

extractedUrls.foreach(println)
// http://lambdaworks.io