Пример
core-js 3.50.0: Demonstrate that core-js 3.50 captures the built-in URL.prototype.toString when installing a missing URL.prototype.toJSON, so later prototype reassignment does not corrupt URL JSON serialization.
Проверенный пример — npm core-js 3.50.0: Demonstrate that core-js 3.50 captures the built-in URL.prototype.toString when installing a missing…
sha256:771727fb4ca310f83f1ec90c4a2f32315fedc9adae20af901d39e2e339f493f2
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 3
- Ключи подписи, собравшие его
- 3
Заявленная среда
node linux x64 node node npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-08 |
Кейс
HOW- Цель
- Demonstrate that core-js 3.50 captures the built-in URL.prototype.toString when installing a missing URL.prototype.toJSON, so later prototype reassignment does not corrupt URL JSON serialization.
- Пакеты
- Символы
-
- core-js/actual/url
- URL.prototype.toJSON
- URL.prototype.toString
- URL.prototype.pathname
- Окружение
- node
- Создан
- 2026-08-17T01:49:38Z
Контракт
- When the host URL.prototype.toJSON is absent, importing core-js/actual/url installs the method while retaining a compliant native URL constructor.
- The installed toJSON serializes an opaque mailto URL as mailto:sample-user and its pathname remains sample-user.
- After URL.prototype.toString is reassigned, String(url) observes the replacement but url.toJSON() still returns the original serialized URL.
Файлы
- csx.json
- package-lock.json
- package.json
- test/contract.cjs
Исходный код
{"case":{"believed":"A core-js-provided URL.prototype.toJSON dynamically calls the current URL.prototype.toString, so reassigning toString later also changes toJSON output.","caseId":"case:sha256:3049a3f86fc4d565f81e64db90f71af745601378421eb1a58c434fd09003aaad","contract":["When the host URL.prototype.toJSON is absent, importing core-js/actual/url installs the method while retaining a compliant native URL constructor.","The installed toJSON serializes an opaque mailto URL as mailto:sample-user and its pathname remains sample-user.","After URL.prototype.toString is reassigned, String(url) observes the replacement but url.toJSON() still returns the original serialized URL."],"goal":"Demonstrate that core-js 3.50 captures the built-in URL.prototype.toString when installing a missing URL.prototype.toJSON, so later prototype reassignment does not corrupt URL JSON serialization.","kind":"HOW","packages":["pkg:npm/core-js@3.50.0"],"schemaVersion":1,"symbols":["core-js/actual/url","URL.prototype.toJSON","URL.prototype.toString","URL.prototype.pathname"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/core-js@3.50.0"],"schemaVersion":1,"symbols":["core-js/actual/url","URL.prototype.toJSON","URL.prototype.toString","URL.prototype.pathname"],"verifierAdapter":"node-typescript@1"}
{
"name": "csx-core-js-url-to-json-contract",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "csx-core-js-url-to-json-contract",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"core-js": "3.50.0"
}
},
"node_modules/core-js": {
"version": "3.50.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.50.0.tgz",
"integrity": "sha512-BRWgOLKkFeCgRudR6zrs8p9XJZcE14grzKMMssoYrk6krtuEZ7MTKPIY5RzOnqsEKIR9kst7wNzphttraT+Yqw==",
"hasInstallScript": true,
"license": "MIT",
"engines": {
"node": "*"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
}
}
}
{
"name": "csx-core-js-url-to-json-contract",
"version": "1.0.0",
"private": true,
"type": "commonjs",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"core-js": "3.50.0"
}
}
'use strict';
const assert = require('node:assert/strict');
const NativeURL = globalThis.URL;
const toJSONDescriptor = Object.getOwnPropertyDescriptor(NativeURL.prototype, 'toJSON');
const toStringDescriptor = Object.getOwnPropertyDescriptor(NativeURL.prototype, 'toString');
assert.equal(toJSONDescriptor?.configurable, true);
assert.equal(typeof toStringDescriptor?.value, 'function');
try {
delete NativeURL.prototype.toJSON;
assert.equal(NativeURL.prototype.toJSON, undefined);
const URL = require('core-js/actual/url');
assert.equal(URL, NativeURL);
assert.equal(typeof URL.prototype.toJSON, 'function');
const url = new URL('mailto:sample-user');
assert.equal(url.href, 'mailto:sample-user');
assert.equal(url.pathname, 'sample-user');
assert.equal(url.toJSON(), 'mailto:sample-user');
URL.prototype.toString = function toString() {
return 'reassigned';
};
assert.equal(String(url), 'reassigned');
assert.equal(url.toJSON(), 'mailto:sample-user');
} finally {
Object.defineProperty(NativeURL.prototype, 'toString', toStringDescriptor);
Object.defineProperty(NativeURL.prototype, 'toJSON', toJSONDescriptor);
}