Skip to content

Commit 93a52b6

Browse files
committed
fix: 修复cURL(CMD)中文转义符移除不完整问题 & 添加编辑器软换行防止长行撑开容器
1 parent b8920d6 commit 93a52b6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/frontEnd/src/components/HttpCodeEditor.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ function createEditorState(content: string): EditorState {
337337
highlightSelectionMatches(),
338338
syntaxHighlighting(httpHighlightStyle),
339339
httpLanguage,
340+
EditorView.lineWrapping, // 启用软换行,防止长行撑开容器
340341
themeCompartment.of(getCurrentTheme()),
341342
keymap.of([
342343
...defaultKeymap,

src/frontEnd/src/utils/httpRequestParser/parsers/curlParser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,15 @@ export function parseCurlCmd(input: string): ParsedHttpRequest | null {
145145
// Step 5: 处理剩余的 ^^ => ^ (转义的脱字符本身)
146146
normalized = normalized.replace(/\^\^/g, '^')
147147

148+
// Step 6: 移除非ASCII字符(中文等)前的 ^
149+
// Windows CMD 中 ^ 也用于转义中文等多字节字符,如 ^电^话 => 电话
150+
normalized = normalized.replace(/\^([^\x00-\x7F])/g, '$1')
151+
148152
// 使用库解析标准化后的 cURL 命令
149153
const result = parseCurlWithLib(normalized)
150154

151155
if (result) {
152-
// Step 6: 恢复占位符为实际的引号字符
156+
// Step 7: 恢复占位符为实际的引号字符
153157
const restorePlaceholder = (str: string) =>
154158
str.replace(new RegExp(NESTED_QUOTE_PLACEHOLDER, 'g'), '"')
155159

0 commit comments

Comments
 (0)