bare-url 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.c +49 -4
- package/index.js +15 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/bare-url.bare +0 -0
- package/prebuilds/darwin-x64/bare-url.bare +0 -0
- package/prebuilds/linux-arm64/bare-url.bare +0 -0
- package/prebuilds/linux-x64/bare-url.bare +0 -0
- package/prebuilds/win32-x64/bare-url.bare +0 -0
package/binding.c
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#include <utf.h>
|
|
9
9
|
#include <utf/string.h>
|
|
10
10
|
|
|
11
|
+
static js_type_tag_t bare_url__tag = {0x6f1fd92f476698b0, 0x93b59c349143ee50};
|
|
12
|
+
|
|
11
13
|
static js_value_t *
|
|
12
14
|
bare_url_parse (js_env_t *env, js_callback_info_t *info) {
|
|
13
15
|
int err;
|
|
@@ -57,10 +59,6 @@ bare_url_parse (js_env_t *env, js_callback_info_t *info) {
|
|
|
57
59
|
err = js_get_value_string_utf8(env, argv[0], input, len, NULL);
|
|
58
60
|
assert(err == 0);
|
|
59
61
|
|
|
60
|
-
uint32_t *components;
|
|
61
|
-
err = js_get_typedarray_info(env, argv[2], NULL, (void **) &components, NULL, NULL, NULL);
|
|
62
|
-
assert(err == 0);
|
|
63
|
-
|
|
64
62
|
js_value_t *handle;
|
|
65
63
|
|
|
66
64
|
url_t url;
|
|
@@ -83,6 +81,10 @@ bare_url_parse (js_env_t *env, js_callback_info_t *info) {
|
|
|
83
81
|
err = js_create_string_utf8(env, url.href.data, url.href.len, &href);
|
|
84
82
|
assert(err == 0);
|
|
85
83
|
|
|
84
|
+
uint32_t *components;
|
|
85
|
+
err = js_get_typedarray_info(env, argv[2], NULL, (void **) &components, NULL, NULL, NULL);
|
|
86
|
+
assert(err == 0);
|
|
87
|
+
|
|
86
88
|
memcpy(components, &url.components, sizeof(url.components));
|
|
87
89
|
|
|
88
90
|
url_destroy(&base);
|
|
@@ -159,6 +161,47 @@ bare_url_can_parse (js_env_t *env, js_callback_info_t *info) {
|
|
|
159
161
|
return result;
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
static js_value_t *
|
|
165
|
+
bare_url_tag (js_env_t *env, js_callback_info_t *info) {
|
|
166
|
+
int err;
|
|
167
|
+
|
|
168
|
+
size_t argc = 1;
|
|
169
|
+
js_value_t *argv[1];
|
|
170
|
+
|
|
171
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
172
|
+
assert(err == 0);
|
|
173
|
+
|
|
174
|
+
assert(argc == 1);
|
|
175
|
+
|
|
176
|
+
err = js_add_type_tag(env, argv[0], &bare_url__tag);
|
|
177
|
+
assert(err == 0);
|
|
178
|
+
|
|
179
|
+
return NULL;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static js_value_t *
|
|
183
|
+
bare_url_is_tagged (js_env_t *env, js_callback_info_t *info) {
|
|
184
|
+
int err;
|
|
185
|
+
|
|
186
|
+
size_t argc = 1;
|
|
187
|
+
js_value_t *argv[1];
|
|
188
|
+
|
|
189
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
190
|
+
assert(err == 0);
|
|
191
|
+
|
|
192
|
+
assert(argc == 1);
|
|
193
|
+
|
|
194
|
+
bool is_url;
|
|
195
|
+
err = js_check_type_tag(env, argv[0], &bare_url__tag, &is_url);
|
|
196
|
+
assert(err == 0);
|
|
197
|
+
|
|
198
|
+
js_value_t *result;
|
|
199
|
+
err = js_get_boolean(env, is_url, &result);
|
|
200
|
+
assert(err == 0);
|
|
201
|
+
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
162
205
|
static js_value_t *
|
|
163
206
|
bare_url_exports (js_env_t *env, js_value_t *exports) {
|
|
164
207
|
int err;
|
|
@@ -174,6 +217,8 @@ bare_url_exports (js_env_t *env, js_value_t *exports) {
|
|
|
174
217
|
|
|
175
218
|
V("parse", bare_url_parse)
|
|
176
219
|
V("canParse", bare_url_can_parse)
|
|
220
|
+
V("tag", bare_url_tag)
|
|
221
|
+
V("isTagged", bare_url_is_tagged)
|
|
177
222
|
#undef V
|
|
178
223
|
|
|
179
224
|
return exports;
|
package/index.js
CHANGED
|
@@ -7,6 +7,10 @@ const errors = require('./lib/errors')
|
|
|
7
7
|
const isWindows = Bare.platform === 'win32'
|
|
8
8
|
|
|
9
9
|
const URL = module.exports = exports = class URL {
|
|
10
|
+
static {
|
|
11
|
+
binding.tag(this)
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
constructor (href, base) {
|
|
11
15
|
if (typeof href !== 'string') throw errors.INVALID_URL()
|
|
12
16
|
|
|
@@ -236,7 +240,17 @@ function cannotHaveCredentialsOrPort (url) {
|
|
|
236
240
|
exports.URL = exports // For Node.js compatibility
|
|
237
241
|
|
|
238
242
|
exports.isURL = function isURL (value) {
|
|
239
|
-
|
|
243
|
+
if (typeof value !== 'object' || value === null) return false
|
|
244
|
+
|
|
245
|
+
let constructor = value.constructor
|
|
246
|
+
|
|
247
|
+
while (typeof constructor === 'function') {
|
|
248
|
+
if (binding.isTagged(constructor)) return true
|
|
249
|
+
|
|
250
|
+
constructor = Reflect.getPrototypeOf(constructor)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return false
|
|
240
254
|
}
|
|
241
255
|
|
|
242
256
|
exports.canParse = function canParse (href, base) {
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|