Skip to content

Commit

Permalink
add a fix of Bun URL.canParse arity
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 13, 2024
1 parent 181e0e7 commit 50fad42
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fixed some validation cases in `Object.setPrototypeOf`, [#1329](https://github.com/zloirock/core-js/issues/1329), thanks [**@minseok-choe**](https://github.com/minseok-choe)
- Fixed the order of validations in `Array.from`, [#1331](https://github.com/zloirock/core-js/pull/1331), thanks [**@minseok-choe**](https://github.com/minseok-choe)
- Added a fix of [Bun `queueMicrotask` arity](https://github.com/oven-sh/bun/issues/9249)
- Added a fix of [Bun `URL.canParse` arity](https://github.com/oven-sh/bun/issues/9250)
- Compat data improvements:
- Added React Native 0.74 Hermes compat data, `Array.prototype.{ toSpliced, toReversed, with }` and `atob` marked as supported
- Added Deno 1.41.3 compat data mapping
Expand Down
4 changes: 3 additions & 1 deletion packages/core-js-compat/src/data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2635,7 +2635,9 @@ export const data = {
safari: '14.0',
},
'web.url.can-parse': {
bun: '1.0.2',
// Bun ~ 1.0.30 bug
// https://github.com/oven-sh/bun/issues/9250
// bun: '1.0.2',
chrome: '120',
deno: '1.33.2',
firefox: '115',
Expand Down
8 changes: 7 additions & 1 deletion packages/core-js/modules/web.url.can-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ var THROWS_WITHOUT_ARGUMENTS = USE_NATIVE_URL && fails(function () {
URL.canParse();
});

// Bun ~ 1.0.30 bug
// https://github.com/oven-sh/bun/issues/9250
var WRONG_ARITY = fails(function () {
return URL.canParse !== 1;
});

// `URL.canParse` method
// https://url.spec.whatwg.org/#dom-url-canparse
$({ target: 'URL', stat: true, forced: !THROWS_WITHOUT_ARGUMENTS }, {
$({ target: 'URL', stat: true, forced: !THROWS_WITHOUT_ARGUMENTS || WRONG_ARITY }, {
canParse: function canParse(url) {
var length = validateArgumentsLength(arguments.length, 1);
var urlString = toString(url);
Expand Down
2 changes: 1 addition & 1 deletion tests/compat/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ GLOBAL.tests = {
try {
URL.canParse();
} catch (error) {
return URL.canParse;
return URL.canParse.length === 1;
}
}],
'web.url.to-json': [URL_AND_URL_SEARCH_PARAMS_SUPPORT, function () {
Expand Down

0 comments on commit 50fad42

Please sign in to comment.