Skip to content

Commit

Permalink
Add support for WEBDAV verbs (#1030)
Browse files Browse the repository at this point in the history
Co-authored-by: Terje Nagel <[email protected]>
  • Loading branch information
ternag and tna-schultz authored Jul 24, 2023
1 parent 243463a commit a89f8bc
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"folding": {
"markers": {
"start": "^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|curl)\\s+",
"start": "^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH|curl)\\s+",
"end": "^#{3,}$"
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
".http",
".rest"
],
"firstLine": "^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE)\\s+(.*?)HTTP/[0-9\\.]+$",
"firstLine": "^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH)\\s+(.*?)HTTP/[0-9\\.]+$",
"configuration": "./language-configuration.json"
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/utils/curlRequestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CurlRequestParser implements RequestParser {
let requestText = CurlRequestParser.mergeMultipleSpacesIntoSingle(
CurlRequestParser.mergeIntoSingleLine(this.requestRawText.trim()));
requestText = requestText
.replace(/(-X)(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE)/, '$1 $2')
.replace(/(-X)(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH)/, '$1 $2')
.replace(/(-I|--head)(?=\s+)/, '-X HEAD');
const parsedArguments = yargsParser(requestText);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/httpElementFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class HttpElementFactory {
return;
}
const prefixLength = protocol.length + 2; // https: + //
originalElements.push(new HttpElement(`${requestUrl.substr(prefixLength)}`, ElementType.URL, '^\\s*(?:(?:GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE)\\s+)https?\\:\\/{2}'));
originalElements.push(new HttpElement(`${requestUrl.substr(prefixLength)}`, ElementType.URL, '^\\s*(?:(?:GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH)\\s+)https?\\:\\/{2}'));
});

let elements: HttpElement[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/httpRequestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class HttpRequestParser implements RequestParser {
let url: string;

let match: RegExpExecArray | null;
if (match = /^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE)\s+/i.exec(line)) {
if (match = /^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|CONNECT|TRACE|LOCK|UNLOCK|PROPFIND|PROPPATCH|COPY|MOVE|MKCOL|MKCALENDAR|ACL|SEARCH)\s+/i.exec(line)) {
method = match[1];
url = line.substr(match[0].length);
} else {
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/http.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
]
}
},
"match": "(?i)^(?:(get|post|put|delete|patch|head|options|connect|trace)\\s+)?\\s*(.+?)(?:\\s+(HTTP\\/\\S+))?$",
"match": "(?i)^(?:(get|post|put|delete|patch|head|options|connect|trace|lock|unlock|propfind|proppatch|copy|move|mkcol|mkcalendar|acl|search)\\s+)?\\s*(.+?)(?:\\s+(HTTP\\/\\S+))?$",
"name": "http.requestline"
},
"response-line": {
Expand Down

0 comments on commit a89f8bc

Please sign in to comment.