diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala index 7454a6287..bc5fc8722 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala @@ -12,5 +12,13 @@ class URLTest extends AnyFunSpec { myURL.search = "abc=xyz" assert(myURL.href === "https://example.org/abc?abc=xyz") } + + it("should support base URL string") { + val url1 = new URL("/abc?123", "https://example.org") + assert(url1.href === "https://example.org/abc?123") + + val url2 = new URL("/abc?123", new URL("https://example.org")) + assert(url2.href === "https://example.org/abc?123") + } } } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala index d5436b456..781b7f63f 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala @@ -5,17 +5,12 @@ import scala.scalajs.js import scala.scalajs.js.annotation.JSImport import scala.scalajs.js.| -/** - * This module has utilities for URL resolution and parsing. Call require('url') to use it. - * @param input The input URL to parse - * @param base The base URL to resolve against if the input is not absolute. - * @see https://nodejs.org/api/url.html - */ @js.native @JSImport("url", "URL") -class URL(input: String, base: String) extends js.Object { - def this(input: String, base: URL) = this(input, "") - def this(input: String) = this(input, "") +class URL protected () extends js.Object { + def this(input: String, base: String) = this() + def this(input: String, base: URL) = this() + def this(input: String) = this() /** * The auth property is the username and password portion of the URL, also referred to as "userinfo".