| 151 | }; |
| 152 | |
| 153 | const convertFileSrcServerUrl = (webviewServerUrl: string, filePath: string): string => { |
| 154 | if (typeof filePath === 'string') { |
| 155 | if (filePath.startsWith('/')) { |
| 156 | return webviewServerUrl + '/_capacitor_file_' + filePath; |
| 157 | } else if (filePath.startsWith('file://')) { |
| 158 | return webviewServerUrl + filePath.replace('file://', '/_capacitor_file_'); |
| 159 | } else if (filePath.startsWith('content://')) { |
| 160 | return webviewServerUrl + filePath.replace('content:/', '/_capacitor_content_'); |
| 161 | } |
| 162 | } |
| 163 | return filePath; |
| 164 | }; |
| 165 | |
| 166 | const initEvents = (win: WindowCapacitor, cap: CapacitorInstance) => { |
| 167 | cap.addListener = (pluginName, eventName, callback) => { |