| 113 | } |
| 114 | |
| 115 | function getMimeType(path: string, isdir: boolean): string { |
| 116 | if (isdir) { |
| 117 | return MockDirMimeType; |
| 118 | } |
| 119 | if (path.endsWith(".md")) { |
| 120 | return "text/markdown"; |
| 121 | } |
| 122 | if (path.endsWith(".json")) { |
| 123 | return "application/json"; |
| 124 | } |
| 125 | if (path.endsWith(".ts")) { |
| 126 | return "text/typescript"; |
| 127 | } |
| 128 | if (path.endsWith(".tsx")) { |
| 129 | return "text/tsx"; |
| 130 | } |
| 131 | if (path.endsWith(".js")) { |
| 132 | return "text/javascript"; |
| 133 | } |
| 134 | if (path.endsWith(".txt") || path.endsWith(".log") || path.endsWith(".bashrc") || path.endsWith(".zprofile")) { |
| 135 | return "text/plain"; |
| 136 | } |
| 137 | if (path.endsWith(".png")) { |
| 138 | return "image/png"; |
| 139 | } |
| 140 | if (path.endsWith(".jpg") || path.endsWith(".jpeg")) { |
| 141 | return "image/jpeg"; |
| 142 | } |
| 143 | if (path.endsWith(".pdf")) { |
| 144 | return "application/pdf"; |
| 145 | } |
| 146 | if (path.endsWith(".zip")) { |
| 147 | return "application/zip"; |
| 148 | } |
| 149 | if (path.endsWith(".dmg")) { |
| 150 | return "application/x-apple-diskimage"; |
| 151 | } |
| 152 | if (path.endsWith(".svg")) { |
| 153 | return "image/svg+xml"; |
| 154 | } |
| 155 | if (path.endsWith(".yaml") || path.endsWith(".yml")) { |
| 156 | return "application/yaml"; |
| 157 | } |
| 158 | return "application/octet-stream"; |
| 159 | } |
| 160 | |
| 161 | function makeContentBytes(content: string | Uint8Array): Uint8Array { |
| 162 | if (content instanceof Uint8Array) { |