diff --git a/lib/internal/url.js b/lib/internal/url.js index 9a70838c30..74d8de63d9 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -556,8 +556,6 @@ Object.defineProperties(URL.prototype, { const ctx = this[context]; // toUSVString is not needed. hash = `${hash}`; - if (this.protocol === 'javascript:') - return; if (!hash) { ctx.fragment = null; ctx.flags &= ~binding.URL_FLAGS_HAS_FRAGMENT; diff --git a/test/fixtures/url-setter-tests.js b/test/fixtures/url-setter-tests.js index d0688611a0..4c39cb7311 100644 --- a/test/fixtures/url-setter-tests.js +++ b/test/fixtures/url-setter-tests.js @@ -1800,13 +1800,13 @@ module.exports = "hash": "#%c3%89t%C3%A9" } }, - // { - // "href": "javascript:alert(1)", - // "new_value": "castle", - // "expected": { - // "href": "javascript:alert(1)#castle", - // "hash": "#castle" - // } - // } + { + "href": "javascript:alert(1)", + "new_value": "castle", + "expected": { + "href": "javascript:alert(1)#castle", + "hash": "#castle" + } + } ] }