1
1
package io .scalajs .nodejs
2
2
package url
3
3
4
+ import com .thoughtworks .enableIf
4
5
import io .scalajs .nodejs .events .IEventEmitter
5
6
6
7
import scala .scalajs .js
@@ -114,20 +115,16 @@ object URL extends IEventEmitter {
114
115
* Take a parsed URL object, and return a formatted URL string.
115
116
* @example url.format(urlObj)
116
117
*/
118
+ @ deprecated(" Use URL instead" , " Node.js v11.0.0" )
117
119
def format (urlObj : URLObject ): String = js.native
118
120
119
121
/**
120
- * Take a URL string, and return an object.
121
- *
122
- * Pass true as the second argument to also parse the query string using the querystring module. If true then the
123
- * query property will always be assigned an object, and the search property will always be a (possibly empty)
124
- * string. If false then the query property will not be parsed or decoded. Defaults to false.
125
- *
126
- * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather
127
- * than { pathname: '//foo/bar' }. Defaults to false.
128
- * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost])
122
+ * Returns a customizable serialization of a URL String representation of a WHATWG URL object.
123
+ * @param url the given [[URL ]]
124
+ * @param options the given [[UrlFormatOptions options ]]
125
+ * @return a customizable serialization of a URL String representation of a WHATWG URL object.
129
126
*/
130
- def parse ( urlStr : String , parseQueryString : String , slashesDenoteHost : Boolean ): URLObject = js.native
127
+ def format ( url : URL , options : UrlFormatOptions = js.native ): String = js.native
131
128
132
129
/**
133
130
* Take a URL string, and return an object.
@@ -140,32 +137,13 @@ object URL extends IEventEmitter {
140
137
* than { pathname: '//foo/bar' }. Defaults to false.
141
138
* @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost])
142
139
*/
143
- def parse (urlStr : String , parseQueryString : String ): URLObject = js.native
140
+ @ deprecated(" Use URL instead" , " Node.js v11.0.0" )
141
+ def parse (urlStr : String , parseQueryString : Boolean , slashesDenoteHost : Boolean ): URLObject = js.native
144
142
145
- /**
146
- * Take a URL string, and return an object.
147
- *
148
- * Pass true as the second argument to also parse the query string using the querystring module. If true then the
149
- * query property will always be assigned an object, and the search property will always be a (possibly empty)
150
- * string. If false then the query property will not be parsed or decoded. Defaults to false.
151
- *
152
- * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather
153
- * than { pathname: '//foo/bar' }. Defaults to false.
154
- * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost])
155
- */
156
- def parse (urlStr : String , slashesDenoteHost : Boolean ): URLObject = js.native
143
+ @ deprecated(" Use URL instead" , " Node.js v11.0.0" )
144
+ def parse (urlStr : String , parseQueryString : Boolean ): URLObject = js.native
157
145
158
- /**
159
- * Take a URL string, and return an object.
160
- *
161
- * Pass true as the second argument to also parse the query string using the querystring module. If true then the
162
- * query property will always be assigned an object, and the search property will always be a (possibly empty)
163
- * string. If false then the query property will not be parsed or decoded. Defaults to false.
164
- *
165
- * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather
166
- * than { pathname: '//foo/bar' }. Defaults to false.
167
- * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost])
168
- */
146
+ @ deprecated(" Use URL instead" , " Node.js v11.0.0" )
169
147
def parse (urlStr : String ): URLObject = js.native
170
148
171
149
/**
@@ -176,6 +154,27 @@ object URL extends IEventEmitter {
176
154
* url.resolve('http://example.com/one', '/two') // 'http://example.com/two'
177
155
* @example url.resolve(from, to)
178
156
*/
157
+ @ deprecated(" Use URL instead" , " Node.js v11.0.0" )
179
158
def resolve (from : String , to : String ): String = js.native
180
159
160
+ /**
161
+ * Returns the Punycode ASCII serialization of the domain. If domain is an invalid domain, the empty string is returned.
162
+ * @param domain the domain
163
+ * @return the Punycode ASCII serialization of the domain
164
+ */
165
+ def domainToASCII (domain : String ): String = js.native
166
+
167
+ /**
168
+ * Returns the Unicode serialization of the domain. If domain is an invalid domain, the empty string is returned.
169
+ * @param domain the domain
170
+ * @return the Unicode serialization of the domain
171
+ */
172
+ def domainToUnicode (domain : String ): String = js.native
173
+
174
+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
175
+ def fileURLToPath (url : URL | String ): String = js.native
176
+
177
+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
178
+ def pathToFileURL (url : String ): URL = js.native
179
+
181
180
}
0 commit comments