Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit e182445

Browse files
authored
Merge pull request #274 from exoego/cleanup
[refactoring] Cleanup constructor
2 parents 5334171 + 5b9d684 commit e182445

File tree

2 files changed

+12
-9
lines changed
  • app
    • nodejs-v10/src/test/scala/io/scalajs/nodejs/url
    • nodejs-v14/src/main/scala/io/scalajs/nodejs/url

2 files changed

+12
-9
lines changed

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@ class URLTest extends AnyFunSpec {
1212
myURL.search = "abc=xyz"
1313
assert(myURL.href === "https://example.org/abc?abc=xyz")
1414
}
15+
16+
it("should support base URL string") {
17+
val url1 = new URL("/abc?123", "https://example.org")
18+
assert(url1.href === "https://example.org/abc?123")
19+
20+
val url2 = new URL("/abc?123", new URL("https://example.org"))
21+
assert(url2.href === "https://example.org/abc?123")
22+
}
1523
}
1624
}

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ import scala.scalajs.js
55
import scala.scalajs.js.annotation.JSImport
66
import scala.scalajs.js.|
77

8-
/**
9-
* This module has utilities for URL resolution and parsing. Call require('url') to use it.
10-
* @param input The input URL to parse
11-
* @param base The base URL to resolve against if the input is not absolute.
12-
* @see https://nodejs.org/api/url.html
13-
*/
148
@js.native
159
@JSImport("url", "URL")
16-
class URL(input: String, base: String) extends js.Object {
17-
def this(input: String, base: URL) = this(input, "")
18-
def this(input: String) = this(input, "")
10+
class URL protected () extends js.Object {
11+
def this(input: String, base: String) = this()
12+
def this(input: String, base: URL) = this()
13+
def this(input: String) = this()
1914

2015
/**
2116
* The auth property is the username and password portion of the URL, also referred to as "userinfo".

0 commit comments

Comments
 (0)