(str)
| 43 | |
| 44 | // https://github.com/web-platform-tests/wpt/blob/b24eedd/resources/testharness.js#L3705 |
| 45 | function sanitizeUnpairedSurrogates(str) { |
| 46 | return str.replace( |
| 47 | /([\ud800-\udbff]+)(?![\udc00-\udfff])|(^|[^\ud800-\udbff])([\udc00-\udfff]+)/g, |
| 48 | function(_, low, prefix, high) { |
| 49 | let output = prefix || ''; // Prefix may be undefined |
| 50 | const string = low || high; // Only one of these alternates can match |
| 51 | for (let i = 0; i < string.length; i++) { |
| 52 | output += codeUnitStr(string[i]); |
| 53 | } |
| 54 | return output; |
| 55 | }); |
| 56 | } |
| 57 | |
| 58 | function codeUnitStr(char) { |
| 59 | return 'U+' + char.charCodeAt(0).toString(16); |
no test coverage detected
searching dependent graphs…