MCPcopy Create free account
hub / github.com/nodejs/node / encode

Function encode

test/fixtures/wpt/encoding/resources/encode-href-common.js:7–18  ·  view source on GitHub ↗
(input, expected, desc)

Source from the content-addressed store, hash-verified

5// expect (function)
6
7function encode(input, expected, desc) {
8 // tests whether a Unicode character is converted to an equivalent byte sequence by href
9 // input: a Unicode character
10 // expected: expected byte sequence
11 // desc: what's being tested
12 subsetTest(test, function() {
13 var a = document.createElement("a"); // <a> uses document encoding for URL's query
14 a.href = "https://example.com/?" + input;
15 result = a.search.substr(1); // remove leading "?"
16 assert_equals(normalizeStr(result), normalizeStr(expected));
17 }, desc);
18}
19
20// set up a simple array of unicode codepoints that are not encoded
21var codepoints = [];

Callers 1

Calls 4

subsetTestFunction · 0.85
createElementMethod · 0.80
assert_equalsFunction · 0.50
normalizeStrFunction · 0.50

Tested by

no test coverage detected