Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-jsoneditor

Package Overview
Dependencies
Maintainers
1
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-jsoneditor - npm Package Compare versions

Comparing version 0.21.5 to 0.21.6

16

package.json
{
"name": "svelte-jsoneditor",
"description": "A web-based tool to view, edit, format, transform, and validate JSON",
"version": "0.21.5",
"version": "0.21.6",
"homepage": "https://github.com/josdejong/svelte-jsoneditor",

@@ -40,7 +40,7 @@ "repository": {

"@codemirror/lang-json": "^6.0.1",
"@codemirror/language": "^6.10.0",
"@codemirror/lint": "^6.4.2",
"@codemirror/search": "^6.5.5",
"@codemirror/language": "^6.10.1",
"@codemirror/lint": "^6.5.0",
"@codemirror/search": "^6.5.6",
"@codemirror/state": "^6.4.0",
"@codemirror/view": "^6.23.1",
"@codemirror/view": "^6.24.0",
"@fortawesome/free-regular-svg-icons": "^6.5.1",

@@ -56,3 +56,3 @@ "@fortawesome/free-solid-svg-icons": "^6.5.1",

"json-source-map": "^0.6.1",
"jsonrepair": "^3.5.1",
"jsonrepair": "^3.6.0",
"lodash-es": "^4.17.21",

@@ -62,6 +62,6 @@ "memoize-one": "^6.0.0",

"sass": "^1.70.0",
"svelte": "^4.2.9",
"svelte": "^4.2.10",
"svelte-awesome": "^3.3.1",
"svelte-select": "^5.8.3",
"svelte-simple-modal": "^1.6.1",
"svelte-simple-modal": "^1.6.2",
"vanilla-picker": "^2.12.2"

@@ -68,0 +68,0 @@ },

@@ -251,3 +251,3 @@ import type { JSONPatchDocument, JSONPath, JSONPointer } from 'immutable-json-patch';

export type RenderMenuContext = {
mode: 'tree' | 'text' | 'table';
mode: Mode;
modal: boolean;

@@ -371,3 +371,3 @@ };

escapeUnicodeCharacters?: boolean;
flattenColumns?: true;
flattenColumns?: boolean;
parser?: JSONParser;

@@ -374,0 +374,0 @@ validator?: Validator | null;

@@ -404,6 +404,7 @@ import { compileJSONPointer } from 'immutable-json-patch';

export function needsFormatting(jsonText) {
// the check for the length>2 is because an empty array or object does not need formatting
return NEEDS_FORMATTING_REGEX.test(jsonText) && jsonText.length > 2;
const maxLength = 999;
const head = jsonText.substring(0, maxLength);
return !head.includes('\n') && DELIMITER_WITHOUT_SPACING_REGEX.test(head);
}
// regex that matches the start of an object or array, followed by a non-whitespace character
const NEEDS_FORMATTING_REGEX = /^[[{]\S/;
// This regex matches cases of a comma or colon NOT followed by a whitespace
const DELIMITER_WITHOUT_SPACING_REGEX = /[,:]\S/;

@@ -296,4 +296,3 @@ import { test, describe, expect } from 'vitest';

expect(needsFormatting('[\n1,\n 2,\n 3\n]')).toBe(false);
expect(needsFormatting('{\n "a":true,\n "b":false\n}')).toBe(false);
expect(needsFormatting('\n[1,2,3]')).toBe(false);
expect(needsFormatting('{\n "a": true,\n "b": false\n}')).toBe(false);
expect(needsFormatting('1234')).toBe(false);

@@ -304,5 +303,10 @@ expect(needsFormatting('"abc"')).toBe(false);

expect(needsFormatting('null')).toBe(false);
// cannot detect partially formatted content
expect(needsFormatting('[1, 2, 3]')).toBe(true);
expect(needsFormatting('[1, 2, 3]')).toBe(false);
expect(needsFormatting('{"a": 1, "b": 2}')).toBe(false);
expect(needsFormatting('{"a":1, "b":2}')).toBe(true);
expect(needsFormatting('{\n "a": "some:message"\n}')).toBe(false);
expect(needsFormatting('{\n "a": "some,message"\n}')).toBe(false);
// a colon or comma inside a string gives a false positive (when the text doesn't contain a return character)
expect(needsFormatting('{"a": "some:message"}')).toBe(true);
expect(needsFormatting('{"a": "some,message"}')).toBe(true);
});

@@ -309,0 +313,0 @@ });

Sorry, the diff of this file is too big to display

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