Commit 4e7b2a82d733fc705bc4a50192fb1bbe552bc687

Jxck 2021-01-17T01:45:05

HTTP: Allow root path in request line (#2711)

diff --git a/components/prism-http.js b/components/prism-http.js
index 4c20d4e..4f37679 100644
--- a/components/prism-http.js
+++ b/components/prism-http.js
@@ -1,7 +1,7 @@
 (function (Prism) {
 	Prism.languages.http = {
 		'request-line': {
-			pattern: /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S+\sHTTP\/[0-9.]+/m,
+			pattern: /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,
 			inside: {
 				// HTTP Verb
 				'property': /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,
diff --git a/components/prism-http.min.js b/components/prism-http.min.js
index 52a14a7..5b5b842 100644
--- a/components/prism-http.min.js
+++ b/components/prism-http.min.js
@@ -1 +1 @@
-!function(t){t.languages.http={"request-line":{pattern:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S+\sHTTP\/[0-9.]+/m,inside:{property:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,"attr-name":/:\w+/}},"response-status":{pattern:/^HTTP\/1.[01] \d.*/m,inside:{property:{pattern:/(^HTTP\/1.[01] )\d.*/i,lookbehind:!0}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var a,e,n,i=t.languages,p={"application/javascript":i.javascript,"application/json":i.json||i.javascript,"application/xml":i.xml,"text/xml":i.xml,"text/html":i.html,"text/css":i.css},r={"application/json":!0,"application/xml":!0};for(var s in p)if(p[s]){a=a||{};var T=r[s]?(void 0,n=(e=s).replace(/^[a-z]+\//,""),"(?:"+e+"|\\w+/(?:[\\w.-]+\\+)+"+n+"(?![+\\w.-]))"):s;a[s.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+T+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:p[s]}}a&&t.languages.insertBefore("http","header-name",a)}(Prism);
\ No newline at end of file
+!function(t){t.languages.http={"request-line":{pattern:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,inside:{property:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,"attr-name":/:\w+/}},"response-status":{pattern:/^HTTP\/1.[01] \d.*/m,inside:{property:{pattern:/(^HTTP\/1.[01] )\d.*/i,lookbehind:!0}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var a,e,n,i=t.languages,p={"application/javascript":i.javascript,"application/json":i.json||i.javascript,"application/xml":i.xml,"text/xml":i.xml,"text/html":i.html,"text/css":i.css},r={"application/json":!0,"application/xml":!0};for(var s in p)if(p[s]){a=a||{};var T=r[s]?(void 0,n=(e=s).replace(/^[a-z]+\//,""),"(?:"+e+"|\\w+/(?:[\\w.-]+\\+)+"+n+"(?![+\\w.-]))"):s;a[s.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+T+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:p[s]}}a&&t.languages.insertBefore("http","header-name",a)}(Prism);
\ No newline at end of file
diff --git a/tests/languages/http/request-line_feature.test b/tests/languages/http/request-line_feature.test
index 70db1a9..b387625 100644
--- a/tests/languages/http/request-line_feature.test
+++ b/tests/languages/http/request-line_feature.test
@@ -7,6 +7,7 @@ PATCH http://example.com HTTP/1.0
 TRACE http://example.com HTTP/1.0
 CONNECT http://example.com HTTP/1.0
 GET /path/to/foo.html HTTP/1.1
+GET / HTTP/1.1
 
 ----------------------------------------------------
 
@@ -48,9 +49,13 @@ GET /path/to/foo.html HTTP/1.1
 	["request-line", [
 		["property", "GET"],
 		" /path/to/foo.html HTTP/1.1"
+	]],
+	["request-line", [
+		["property", "GET"],
+		" / HTTP/1.1"
 	]]
 ]
 
 ----------------------------------------------------
 
-Checks for request lines.
\ No newline at end of file
+Checks for request lines.