(json)
| 60 | } |
| 61 | |
| 62 | export function syntaxHighlight(json) { |
| 63 | return json.replace( |
| 64 | /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, |
| 65 | function(match) { |
| 66 | let cls = 'json-number'; |
| 67 | if (/^"/.test(match)) { |
| 68 | if (/:$/.test(match)) { |
| 69 | cls = 'json-key'; |
| 70 | match = match.slice(0, -1); |
| 71 | return '<span class="' + cls + '">' + escapeHtml(match) + '</span>:'; |
| 72 | } else { |
| 73 | cls = 'json-string'; |
| 74 | } |
| 75 | } else if (/true|false/.test(match)) { |
| 76 | cls = 'json-boolean'; |
| 77 | } else if (/null/.test(match)) { |
| 78 | cls = 'json-null'; |
| 79 | } |
| 80 | return '<span class="' + cls + '">' + escapeHtml(match) + '</span>'; |
| 81 | } |
| 82 | ); |
| 83 | } |
| 84 | |
| 85 | export function getUrlPath(url) { |
| 86 | try { |
nothing calls this directly
no test coverage detected