Socket
Socket
Sign inDemoInstall

unraw

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unraw - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

changelog.md

@@ -5,2 +5,6 @@ # Change Log

## 1.1.1
- Refactor tests and add more tests
- Fix: properly handle code point escapes that directly follow unicode escapes
## 1.1.0

@@ -7,0 +11,0 @@

5

dist/index.js

@@ -65,4 +65,3 @@ /**

if (surrogateCode !== undefined) {
let parsedSurrogateCode = undefined;
parsedSurrogateCode = parseInt(surrogateCode, 16);
const parsedSurrogateCode = hexToInt(surrogateCode);
if (surrogateCode.length !== 4 || Number.isNaN(parsedSurrogateCode)) {

@@ -158,3 +157,3 @@ // ie, "\u00FF\uF" or "\u00FF\u$$$$"

*/
const escapeMatch = /\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([\s\S]{0,4})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;
const escapeMatch = /\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;
/**

@@ -161,0 +160,0 @@ * Replace raw escape character strings with their escape characters.

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof module&&"object"==typeof module.exports){var r=e(require,exports);void 0!==r&&(module.exports=r)}else"function"==typeof define&&define.amd&&define(["require","exports"],e)}(function(e,r){"use strict";function t(e){return null!==e.match(/[^a-f0-9]/i)?NaN:parseInt(e,16)}function n(e,r){const n=t(e);if(4!==e.length||Number.isNaN(n))throw new SyntaxError("malformed Unicode character escape sequence");if(void 0!==r){let e=void 0;if(e=parseInt(r,16),4!==r.length||Number.isNaN(e))throw new SyntaxError("malformed Unicode character escape sequence");return String.fromCharCode(n,e)}return String.fromCharCode(n)}Object.defineProperty(r,"__esModule",{value:!0});const o=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([\s\S]{0,4})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;r.default=function(e,r=!1){return e.replace(o,function(e,o,a,i,c,u,s,f,d){if(void 0!==o)return"\\";if(void 0!==d)return function(e){switch(e){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";case"0":return"\0";default:return e}}(d);if(void 0!==a)return function(e){const r=t(e);if(2!==e.length||Number.isNaN(r))throw new SyntaxError("malformed hexadecimal character escape sequence");return String.fromCharCode(r)}(a);if(void 0!==i)return function(e){const r=e.length-1,n=t(e.substring(1,r));if("{"!==e.charAt(0)||"}"!==e.charAt(r)||Number.isNaN(n))throw new SyntaxError("malformed Unicode character escape sequence");try{return String.fromCodePoint(n)}catch(e){throw e instanceof RangeError?new SyntaxError("Unicode codepoint must not be greater than 0x10FFFF in escape sequence"):e}}(i);if(void 0!==c)return n(c,u);if(void 0!==s)return n(s);if("0"===f)return"\0";if(void 0!==f)return function(e,r=!1){if(r)throw new SyntaxError('"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead');{const r=parseInt(e,8);return String.fromCharCode(r)}}(f,!r);throw new SyntaxError("malformed escape sequence at end of string")})}});
!function(e){if("object"==typeof module&&"object"==typeof module.exports){var r=e(require,exports);void 0!==r&&(module.exports=r)}else"function"==typeof define&&define.amd&&define(["require","exports"],e)}(function(e,r){"use strict";function t(e){return null!==e.match(/[^a-f0-9]/i)?NaN:parseInt(e,16)}function n(e,r){const n=t(e);if(4!==e.length||Number.isNaN(n))throw new SyntaxError("malformed Unicode character escape sequence");if(void 0!==r){const e=t(r);if(4!==r.length||Number.isNaN(e))throw new SyntaxError("malformed Unicode character escape sequence");return String.fromCharCode(n,e)}return String.fromCharCode(n)}Object.defineProperty(r,"__esModule",{value:!0});const o=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;r.default=function(e,r=!1){return e.replace(o,function(e,o,a,i,c,u,s,f,d){if(void 0!==o)return"\\";if(void 0!==d)return function(e){switch(e){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";case"0":return"\0";default:return e}}(d);if(void 0!==a)return function(e){const r=t(e);if(2!==e.length||Number.isNaN(r))throw new SyntaxError("malformed hexadecimal character escape sequence");return String.fromCharCode(r)}(a);if(void 0!==i)return function(e){const r=e.length-1,n=t(e.substring(1,r));if("{"!==e.charAt(0)||"}"!==e.charAt(r)||Number.isNaN(n))throw new SyntaxError("malformed Unicode character escape sequence");try{return String.fromCodePoint(n)}catch(e){throw e instanceof RangeError?new SyntaxError("Unicode codepoint must not be greater than 0x10FFFF in escape sequence"):e}}(i);if(void 0!==c)return n(c,u);if(void 0!==s)return n(s);if("0"===f)return"\0";if(void 0!==f)return function(e,r=!1){if(r)throw new SyntaxError('"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead');{const r=parseInt(e,8);return String.fromCharCode(r)}}(f,!r);throw new SyntaxError("malformed escape sequence at end of string")})}});
{
"name": "unraw",
"version": "1.1.0",
"version": "1.1.1",
"description": "Convert raw escape sequences to their respective characters (undo String.raw).",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -11,3 +11,4 @@ # unraw

directly with raw strings and you need a way to get them back to normal strings.
Maybe the most signicant use case is when building string template literal tags;
Maybe the most signicant use case is when building
[template literal tags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates);
you can use the `.raw` property of the passed string array to access the raw

@@ -14,0 +15,0 @@ strings, but then you may want to still return normal strings after processing.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc