From 501e84cb18f007d00493fe457241c1ac4151d24d Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 00:27:47 +0900 Subject: [PATCH 01/14] HTTP: add http-version/status-code/reason-phrase for http response --- components/prism-http.js | 18 +++++++++++---- .../http/response-status_feature.test | 22 +++++++++++-------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/components/prism-http.js b/components/prism-http.js index 4f37679e35..c12099800c 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -10,12 +10,22 @@ } }, 'response-status': { - pattern: /^HTTP\/1.[01] \d.*/m, + pattern: /^HTTP\/1.[01] \d+ .+/m, inside: { // Status, e.g. 200 OK - 'property': { - pattern: /(^HTTP\/1.[01] )\d.*/i, - lookbehind: true + 'http-version': { + pattern: /^HTTP\/1.[01]+/, + alias: 'property' + }, + 'status-code': { + pattern: /^(\s)\d+(?=\s)/, + lookbehind: true, + alias: 'number' + }, + 'reason-phrase': { + pattern: /^(\s).+/, + lookbehind: true, + alias: 'string' } } }, diff --git a/tests/languages/http/response-status_feature.test b/tests/languages/http/response-status_feature.test index 7384ff2a89..f911fe96c3 100644 --- a/tests/languages/http/response-status_feature.test +++ b/tests/languages/http/response-status_feature.test @@ -7,23 +7,27 @@ HTTP/1.0 418 I'm a teapot [ ["response-status", [ - "HTTP/1.0 ", - ["property", "200 OK"] + ["http-version", "HTTP/1.0"], + ["status-code", "200"], + ["reason-phrase", "OK"] ]], ["response-status", [ - "HTTP/1.1 ", - ["property", "403 Forbidden"] + ["http-version", "HTTP/1.1"], + ["status-code", "403"], + ["reason-phrase", "Forbidden"] ]], ["response-status", [ - "HTTP/1.1 ", - ["property", "404 Not Found"] + ["http-version", "HTTP/1.1"], + ["status-code", "404"], + ["reason-phrase", "Not Found"] ]], ["response-status", [ - "HTTP/1.0 ", - ["property", "418 I'm a teapot"] + ["http-version", "HTTP/1.0"], + ["status-code", "418"], + ["reason-phrase", "I'm a teapot"] ]] ] ---------------------------------------------------- -Checks for response statuses. \ No newline at end of file +Checks for response statuses. From 60ed53d900d4bad7f64bfb7cb2e45686b1b5030e Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 00:35:22 +0900 Subject: [PATCH 02/14] HTTP: support more http request method --- components/prism-http.js | 8 ++++--- .../http/response-status_feature.test | 24 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/components/prism-http.js b/components/prism-http.js index c12099800c..7201e542d4 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -1,10 +1,10 @@ (function (Prism) { Prism.languages.http = { 'request-line': { - pattern: /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m, + pattern: /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m, inside: { // HTTP Verb - 'property': /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/, + 'property': /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/, // Path or query argument 'attr-name': /:\w+/ } @@ -12,16 +12,18 @@ 'response-status': { pattern: /^HTTP\/1.[01] \d+ .+/m, inside: { - // Status, e.g. 200 OK + // HTTP Version 'http-version': { pattern: /^HTTP\/1.[01]+/, alias: 'property' }, + // Status Code 'status-code': { pattern: /^(\s)\d+(?=\s)/, lookbehind: true, alias: 'number' }, + // Reason Phrase 'reason-phrase': { pattern: /^(\s).+/, lookbehind: true, diff --git a/tests/languages/http/response-status_feature.test b/tests/languages/http/response-status_feature.test index f911fe96c3..678419e55f 100644 --- a/tests/languages/http/response-status_feature.test +++ b/tests/languages/http/response-status_feature.test @@ -6,26 +6,26 @@ HTTP/1.0 418 I'm a teapot ---------------------------------------------------- [ - ["response-status", [ - ["http-version", "HTTP/1.0"], + ["response-status", [ + ["http-version", "HTTP/1.0"], ["status-code", "200"], ["reason-phrase", "OK"] - ]], - ["response-status", [ - ["http-version", "HTTP/1.1"], + ]], + ["response-status", [ + ["http-version", "HTTP/1.1"], ["status-code", "403"], ["reason-phrase", "Forbidden"] - ]], - ["response-status", [ - ["http-version", "HTTP/1.1"], + ]], + ["response-status", [ + ["http-version", "HTTP/1.1"], ["status-code", "404"], ["reason-phrase", "Not Found"] - ]], - ["response-status", [ - ["http-version", "HTTP/1.0"], + ]], + ["response-status", [ + ["http-version", "HTTP/1.0"], ["status-code", "418"], ["reason-phrase", "I'm a teapot"] - ]] + ]] ] ---------------------------------------------------- From a73e864c30c097fddfb7734ca40adf2a3f201578 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 00:58:00 +0900 Subject: [PATCH 03/14] HTTP: support method/request-target/http-version in request-line --- components/prism-http.js | 19 +++- .../languages/http/request-line_feature.test | 98 ++++++++++--------- 2 files changed, 68 insertions(+), 49 deletions(-) diff --git a/components/prism-http.js b/components/prism-http.js index 7201e542d4..af02b5c88a 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -3,10 +3,21 @@ 'request-line': { pattern: /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m, inside: { - // HTTP Verb - 'property': /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/, - // Path or query argument - 'attr-name': /:\w+/ + // HTTP Method + 'method': { + pattern: /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/, + alias: 'property' + }, + // Request Target e.g. http://example.com, /path/to/file + 'request-target': { + pattern: /^(\s)(?:https?:\/\/|\/)\S*(?=\s)/, + lookbehind: true + }, + // HTTP Version + 'http-version': { + pattern: /^(\s)HTTP\/[0-9.]+/, + lookbehind: true + }, } }, 'response-status': { diff --git a/tests/languages/http/request-line_feature.test b/tests/languages/http/request-line_feature.test index b387625765..aeaff831cd 100644 --- a/tests/languages/http/request-line_feature.test +++ b/tests/languages/http/request-line_feature.test @@ -12,50 +12,58 @@ GET / HTTP/1.1 ---------------------------------------------------- [ - ["request-line", [ - ["property", "POST"], - " http://example.com HTTP/1.0" - ]], - ["request-line", [ - ["property", "GET"], - " http://localhost", - ["attr-name", ":9999"], - "/foo.html HTTP/1.1" - ]], - ["request-line", [ - ["property", "PUT"], - " http://www.example.com HTTP/2.0" - ]], - ["request-line", [ - ["property", "DELETE"], - " https://example.com HTTP/1.1" - ]], - ["request-line", [ - ["property", "OPTIONS"], - " https://www.example.com HTTP/1.1" - ]], - ["request-line", [ - ["property", "PATCH"], - " http://example.com HTTP/1.0" - ]], - ["request-line", [ - ["property", "TRACE"], - " 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" - ]], - ["request-line", [ - ["property", "GET"], - " / HTTP/1.1" - ]] -] + ["request-line", [ + ["method","POST"], + ["request-target","http://example.com"], + ["http-version","HTTP/1.0"] + ]], + ["request-line", [ + ["method","GET"], + ["request-target","http://localhost:9999/foo.html"], + ["http-version","HTTP/1.1"] + ]], + ["request-line", [ + ["method","PUT"], + ["request-target","http://www.example.com"], + ["http-version","HTTP/2.0"] + ]], + ["request-line", [ + ["method","DELETE"], + ["request-target","https://example.com"], + ["http-version","HTTP/1.1"] + ]], + ["request-line", [ + ["method","OPTIONS"], + ["request-target","https://www.example.com"], + ["http-version","HTTP/1.1"] + ]], + ["request-line", [ + ["method","PATCH"], + ["request-target","http://example.com"], + ["http-version","HTTP/1.0"] + ]], + ["request-line", [ + ["method","TRACE"], + ["request-target","http://example.com"], + ["http-version","HTTP/1.0"] + ]], + ["request-line", [ + ["method","CONNECT"], + ["request-target","http://example.com"], + ["http-version","HTTP/1.0"] + ]], + ["request-line", [ + ["method","GET"], + ["request-target","/path/to/foo.html"], + ["http-version","HTTP/1.1"] + ]], + ["request-line", [ + ["method","GET"], + ["request-target","/"], + ["http-version","HTTP/1.1"] + ]] + ] ----------------------------------------------------- + ---------------------------------------------------- -Checks for request lines. + Checks for request lines. From 8a1be31bc7c2960b50141b1c115d55c06cff9a8d Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 02:34:00 +0900 Subject: [PATCH 04/14] npm run build --- components/prism-http.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-http.min.js b/components/prism-http.min.js index 5b5b842f2c..87444118eb 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:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,inside:{method:{pattern:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0},"http-version":{pattern:/^(\s)HTTP\/[0-9.]+/,lookbehind:!0}}},"response-status":{pattern:/^HTTP\/1.[01] \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/1.[01]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var e,a,s,n=t.languages,r={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css},i={"application/json":!0,"application/xml":!0};for(var p in r)if(r[p]){e=e||{};var o=i[p]?(void 0,s=(a=p).replace(/^[a-z]+\//,""),"(?:"+a+"|\\w+/(?:[\\w.-]+\\+)+"+s+"(?![+\\w.-]))"):p;e[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+o+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:r[p]}}e&&t.languages.insertBefore("http","header-name",e)}(Prism); \ No newline at end of file From 9ead580d26aebb5fb478265e713c588be2301fc6 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 02:36:29 +0900 Subject: [PATCH 05/14] HTTP: fixup test format --- tests/languages/http/request-line_feature.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/languages/http/request-line_feature.test b/tests/languages/http/request-line_feature.test index aeaff831cd..62b01c46be 100644 --- a/tests/languages/http/request-line_feature.test +++ b/tests/languages/http/request-line_feature.test @@ -62,8 +62,8 @@ GET / HTTP/1.1 ["request-target","/"], ["http-version","HTTP/1.1"] ]] - ] +] - ---------------------------------------------------- +---------------------------------------------------- - Checks for request lines. +Checks for request lines. From a5a71b0a4805e870f0218ac441500dd88e4125f0 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:26:29 +0900 Subject: [PATCH 06/14] HTTP: remove repeating in HTTP version Co-authored-by: Michael Schmidt --- components/prism-http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-http.js b/components/prism-http.js index af02b5c88a..380c064d34 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -25,7 +25,7 @@ inside: { // HTTP Version 'http-version': { - pattern: /^HTTP\/1.[01]+/, + pattern: /^HTTP\/1.[01]/, alias: 'property' }, // Status Code From 23032c9afefbc25a533c798f22dd7d5b6688435d Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:27:02 +0900 Subject: [PATCH 07/14] HTTP: Just allow [A-Z]+ for http method Co-authored-by: Michael Schmidt --- components/prism-http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-http.js b/components/prism-http.js index 380c064d34..6a39b57547 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -5,7 +5,7 @@ inside: { // HTTP Method 'method': { - pattern: /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/, + pattern: /^[A-Z]+\b/, alias: 'property' }, // Request Target e.g. http://example.com, /path/to/file From a4a261d5942fe6784b6838ab6c3370d97f194ce5 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:29:51 +0900 Subject: [PATCH 08/14] HTTP: alias url for request-target --- components/prism-http.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/prism-http.js b/components/prism-http.js index 6a39b57547..f950b8b8c4 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -11,7 +11,8 @@ // Request Target e.g. http://example.com, /path/to/file 'request-target': { pattern: /^(\s)(?:https?:\/\/|\/)\S*(?=\s)/, - lookbehind: true + lookbehind: true, + alias: 'url' }, // HTTP Version 'http-version': { From 5005504d74ae6c0dab6f372824f927a090c32422 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:35:53 +0900 Subject: [PATCH 09/14] HTTP: update request-line_feature.test --- .../languages/http/request-line_feature.test | 178 ++++++++++++------ 1 file changed, 119 insertions(+), 59 deletions(-) diff --git a/tests/languages/http/request-line_feature.test b/tests/languages/http/request-line_feature.test index 62b01c46be..b99af72e84 100644 --- a/tests/languages/http/request-line_feature.test +++ b/tests/languages/http/request-line_feature.test @@ -1,67 +1,127 @@ -POST http://example.com HTTP/1.0 -GET http://localhost:9999/foo.html HTTP/1.1 -PUT http://www.example.com HTTP/2.0 -DELETE https://example.com HTTP/1.1 -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 +GET / HTTP/1.0 GET / HTTP/1.1 +GET /path/to/file HTTP/1.1 +GET /path/to/file?a=1&b=2 HTTP/1.1 +GET http://example.com HTTP/1.1 +GET https://example.com HTTP/1.1 +GET https://example.com/ HTTP/1.1 +GET https://example.com/path/to/file?a=1&b=2 HTTP/1.1 +GET https://example.com:443/path/to/file?a=1&b=2 HTTP/1.1 +GET https://user:pass@example.com:443/path/to/file?a=1&b=2 HTTP/1.1 +HEAD / HTTP/1.1 +POST / HTTP/1.1 +PUT / HTTP/1.1 +DELETE / HTTP/1.1 +CONNECT / HTTP/1.1 +OPTIONS / HTTP/1.1 +TRACE / HTTP/1.1 +PATCH / HTTP/1.1 +PRI / HTTP/1.1 +SEARCH / HTTP/1.1 ---------------------------------------------------- [ - ["request-line", [ - ["method","POST"], - ["request-target","http://example.com"], - ["http-version","HTTP/1.0"] - ]], - ["request-line", [ - ["method","GET"], - ["request-target","http://localhost:9999/foo.html"], - ["http-version","HTTP/1.1"] - ]], - ["request-line", [ - ["method","PUT"], - ["request-target","http://www.example.com"], - ["http-version","HTTP/2.0"] - ]], - ["request-line", [ - ["method","DELETE"], - ["request-target","https://example.com"], - ["http-version","HTTP/1.1"] - ]], - ["request-line", [ - ["method","OPTIONS"], - ["request-target","https://www.example.com"], - ["http-version","HTTP/1.1"] - ]], - ["request-line", [ - ["method","PATCH"], - ["request-target","http://example.com"], - ["http-version","HTTP/1.0"] - ]], - ["request-line", [ - ["method","TRACE"], - ["request-target","http://example.com"], - ["http-version","HTTP/1.0"] - ]], - ["request-line", [ - ["method","CONNECT"], - ["request-target","http://example.com"], - ["http-version","HTTP/1.0"] - ]], - ["request-line", [ - ["method","GET"], - ["request-target","/path/to/foo.html"], - ["http-version","HTTP/1.1"] - ]], - ["request-line", [ - ["method","GET"], - ["request-target","/"], - ["http-version","HTTP/1.1"] - ]] + ["request-line", [ + ["method", "GET"], + ["request-target", "/"], + ["http-version", "HTTP/1.0"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "/path/to/file"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "/path/to/file?a=1&b=2"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "http://example.com"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "https://example.com"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "https://example.com/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "https://example.com/path/to/file?a=1&b=2"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "https://example.com:443/path/to/file?a=1&b=2"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "GET"], + ["request-target", "https://user:pass@example.com:443/path/to/file?a=1&b=2"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "HEAD"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "POST"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "PUT"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "DELETE"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "CONNECT"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "OPTIONS"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "TRACE"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "PATCH"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "PRI"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]], + ["request-line", [ + ["method", "SEARCH"], + ["request-target", "/"], + ["http-version", "HTTP/1.1"] + ]] ] ---------------------------------------------------- From 6981f209fcb5650b268487fd5a1219511e067422 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:36:45 +0900 Subject: [PATCH 10/14] HTTP: re-generate response-status_feature.test --- .../http/response-status_feature.test | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/languages/http/response-status_feature.test b/tests/languages/http/response-status_feature.test index 678419e55f..c882621ba3 100644 --- a/tests/languages/http/response-status_feature.test +++ b/tests/languages/http/response-status_feature.test @@ -6,26 +6,26 @@ HTTP/1.0 418 I'm a teapot ---------------------------------------------------- [ - ["response-status", [ - ["http-version", "HTTP/1.0"], - ["status-code", "200"], - ["reason-phrase", "OK"] - ]], - ["response-status", [ - ["http-version", "HTTP/1.1"], - ["status-code", "403"], - ["reason-phrase", "Forbidden"] - ]], - ["response-status", [ - ["http-version", "HTTP/1.1"], - ["status-code", "404"], - ["reason-phrase", "Not Found"] - ]], - ["response-status", [ - ["http-version", "HTTP/1.0"], - ["status-code", "418"], - ["reason-phrase", "I'm a teapot"] - ]] + ["response-status", [ + ["http-version", "HTTP/1.0"], + ["status-code", "200"], + ["reason-phrase", "OK"] + ]], + ["response-status", [ + ["http-version", "HTTP/1.1"], + ["status-code", "403"], + ["reason-phrase", "Forbidden"] + ]], + ["response-status", [ + ["http-version", "HTTP/1.1"], + ["status-code", "404"], + ["reason-phrase", "Not Found"] + ]], + ["response-status", [ + ["http-version", "HTTP/1.0"], + ["status-code", "418"], + ["reason-phrase", "I'm a teapot"] + ]] ] ---------------------------------------------------- From a1c6456e3781cc372a7ad27746b8abc8e495fa01 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:39:18 +0900 Subject: [PATCH 11/14] HTTP: merge HTTP Version number pattern --- components/prism-http.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-http.js b/components/prism-http.js index f950b8b8c4..dcb1cd09f4 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -22,11 +22,11 @@ } }, 'response-status': { - pattern: /^HTTP\/1.[01] \d+ .+/m, + pattern: /^HTTP\/[0-9.]+ \d+ .+/m, inside: { // HTTP Version 'http-version': { - pattern: /^HTTP\/1.[01]/, + pattern: /^HTTP\/[0-9.]+/, alias: 'property' }, // Status Code From 073eb9248a4660065cf6639cd800e878c7ac9fcb Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:40:34 +0900 Subject: [PATCH 12/14] npm run build --- components/prism-http.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-http.min.js b/components/prism-http.min.js index 87444118eb..ce98c2f150 100644 --- a/components/prism-http.min.js +++ b/components/prism-http.min.js @@ -1 +1 @@ -!function(t){t.languages.http={"request-line":{pattern:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,inside:{method:{pattern:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0},"http-version":{pattern:/^(\s)HTTP\/[0-9.]+/,lookbehind:!0}}},"response-status":{pattern:/^HTTP\/1.[01] \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/1.[01]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var e,a,s,n=t.languages,r={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css},i={"application/json":!0,"application/xml":!0};for(var p in r)if(r[p]){e=e||{};var o=i[p]?(void 0,s=(a=p).replace(/^[a-z]+\//,""),"(?:"+a+"|\\w+/(?:[\\w.-]+\\+)+"+s+"(?![+\\w.-]))"):p;e[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+o+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:r[p]}}e&&t.languages.insertBefore("http","header-name",e)}(Prism); \ No newline at end of file +!function(t){t.languages.http={"request-line":{pattern:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,inside:{method:{pattern:/^[A-Z]+\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0,alias:"url"},"http-version":{pattern:/^(\s)HTTP\/[0-9.]+/,lookbehind:!0}}},"response-status":{pattern:/^HTTP\/[0-9.]+ \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/[0-9.]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var a,e,s,n=t.languages,r={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css},i={"application/json":!0,"application/xml":!0};for(var p in r)if(r[p]){a=a||{};var o=i[p]?(void 0,s=(e=p).replace(/^[a-z]+\//,""),"(?:"+e+"|\\w+/(?:[\\w.-]+\\+)+"+s+"(?![+\\w.-]))"):p;a[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+o+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:r[p]}}a&&t.languages.insertBefore("http","header-name",a)}(Prism); \ No newline at end of file From ca1d631198d77e7c7c40240de6b55e9e13cb0247 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:44:21 +0900 Subject: [PATCH 13/14] HTTP: add property alias to response-status http-version --- components/prism-http.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/prism-http.js b/components/prism-http.js index dcb1cd09f4..4b8bb84db1 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -17,7 +17,8 @@ // HTTP Version 'http-version': { pattern: /^(\s)HTTP\/[0-9.]+/, - lookbehind: true + lookbehind: true, + alias: 'property' }, } }, From 1e71a08dbebe223b1dc822d8651b469e61df4e57 Mon Sep 17 00:00:00 2001 From: Jxck Date: Mon, 18 Jan 2021 23:44:44 +0900 Subject: [PATCH 14/14] npm run build --- components/prism-http.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-http.min.js b/components/prism-http.min.js index ce98c2f150..6df7aaf172 100644 --- a/components/prism-http.min.js +++ b/components/prism-http.min.js @@ -1 +1 @@ -!function(t){t.languages.http={"request-line":{pattern:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,inside:{method:{pattern:/^[A-Z]+\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0,alias:"url"},"http-version":{pattern:/^(\s)HTTP\/[0-9.]+/,lookbehind:!0}}},"response-status":{pattern:/^HTTP\/[0-9.]+ \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/[0-9.]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var a,e,s,n=t.languages,r={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css},i={"application/json":!0,"application/xml":!0};for(var p in r)if(r[p]){a=a||{};var o=i[p]?(void 0,s=(e=p).replace(/^[a-z]+\//,""),"(?:"+e+"|\\w+/(?:[\\w.-]+\\+)+"+s+"(?![+\\w.-]))"):p;a[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+o+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:r[p]}}a&&t.languages.insertBefore("http","header-name",a)}(Prism); \ No newline at end of file +!function(t){t.languages.http={"request-line":{pattern:/^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m,inside:{method:{pattern:/^[A-Z]+\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0,alias:"url"},"http-version":{pattern:/^(\s)HTTP\/[0-9.]+/,lookbehind:!0,alias:"property"}}},"response-status":{pattern:/^HTTP\/[0-9.]+ \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/[0-9.]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var a,e,s,n=t.languages,r={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css},i={"application/json":!0,"application/xml":!0};for(var p in r)if(r[p]){a=a||{};var o=i[p]?(void 0,s=(e=p).replace(/^[a-z]+\//,""),"(?:"+e+"|\\w+/(?:[\\w.-]+\\+)+"+s+"(?![+\\w.-]))"):p;a[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+o+".*)(?:\\r?\\n|\\r){2}[\\s\\S]*","i"),lookbehind:!0,inside:r[p]}}a&&t.languages.insertBefore("http","header-name",a)}(Prism); \ No newline at end of file