Commit f6e81cb4c74556b43be937d173accf0f80aa2078

Thomas Stapleton 2018-04-11T23:08:00

HTTP: Absolute path is a valid request uri (#1388)

diff --git a/components/prism-http.js b/components/prism-http.js
index e7b1574..82bfed7 100644
--- a/components/prism-http.js
+++ b/components/prism-http.js
@@ -1,6 +1,6 @@
 Prism.languages.http = {
 	'request-line': {
-		pattern: /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\shttps?:\/\/\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 76cfffe..0db32ce 100644
--- a/components/prism-http.min.js
+++ b/components/prism-http.min.js
@@ -1 +1 @@
-Prism.languages.http={"request-line":{pattern:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\shttps?:\/\/\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 httpLanguages={"application/json":Prism.languages.javascript,"application/xml":Prism.languages.markup,"text/xml":Prism.languages.markup,"text/html":Prism.languages.markup};for(var contentType in httpLanguages)if(httpLanguages[contentType]){var options={};options[contentType]={pattern:new RegExp("(content-type:\\s*"+contentType+"[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*","i"),lookbehind:!0,inside:{rest:httpLanguages[contentType]}},Prism.languages.insertBefore("http","header-name",options)}
\ No newline at end of file
+Prism.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 httpLanguages={"application/json":Prism.languages.javascript,"application/xml":Prism.languages.markup,"text/xml":Prism.languages.markup,"text/html":Prism.languages.markup};for(var contentType in httpLanguages)if(httpLanguages[contentType]){var options={};options[contentType]={pattern:new RegExp("(content-type:\\s*"+contentType+"[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*","i"),lookbehind:!0,inside:{rest:httpLanguages[contentType]}},Prism.languages.insertBefore("http","header-name",options)}
\ 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 e234374..70db1a9 100644
--- a/tests/languages/http/request-line_feature.test
+++ b/tests/languages/http/request-line_feature.test
@@ -6,6 +6,7 @@ OPTIONS https://www.example.com HTTP/1.1
 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
 
 ----------------------------------------------------
 
@@ -43,6 +44,10 @@ CONNECT http://example.com HTTP/1.0
 	["request-line", [
 		["property", "CONNECT"],
 		" http://example.com HTTP/1.0"
+	]],
+	["request-line", [
+		["property", "GET"],
+		" /path/to/foo.html HTTP/1.1"
 	]]
 ]