Skip to content

Commit 4010b6f

Browse files
committed
dont duplicate constant
1 parent de425a7 commit 4010b6f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

webview-ui/src/utils/__tests__/command-validation.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import {
1313
createCommandValidator,
1414
containsDangerousSubstitution,
1515
protectNewlinesInQuotes,
16+
NEWLINE_PLACEHOLDER,
1617
} from "../command-validation"
1718

1819
describe("protectNewlinesInQuotes", () => {
19-
const placeholder = "___NEWLINE___"
20+
const placeholder = NEWLINE_PLACEHOLDER
2021

2122
describe("basic quote handling", () => {
2223
it("protects newlines in double quotes", () => {

webview-ui/src/utils/command-validation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { parse } from "shell-quote"
22

33
type ShellToken = string | { op: string } | { command: string }
44

5+
/**
6+
* Placeholder used to protect newlines within quoted strings during command parsing.
7+
* This constant is used by the protectNewlinesInQuotes function to temporarily replace
8+
* newlines that appear inside quotes, preventing them from being treated as command separators.
9+
*/
10+
export const NEWLINE_PLACEHOLDER = "___NEWLINE___"
11+
512
/**
613
* # Command Denylist Feature - Longest Prefix Match Strategy
714
*

0 commit comments

Comments
 (0)