( it: string, type: 'libsql' | 'better-sqlite', )
| 308 | }; |
| 309 | |
| 310 | export const normaliseSQLiteUrl = ( |
| 311 | it: string, |
| 312 | type: 'libsql' | 'better-sqlite', |
| 313 | ) => { |
| 314 | if (type === 'libsql') { |
| 315 | if (it.startsWith('file:')) { |
| 316 | return it; |
| 317 | } |
| 318 | try { |
| 319 | const url = parse(it); |
| 320 | if (url.protocol === null) { |
| 321 | return `file:${it}`; |
| 322 | } |
| 323 | return it; |
| 324 | } catch (e) { |
| 325 | return `file:${it}`; |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | if (type === 'better-sqlite') { |
| 330 | if (it.startsWith('file:')) { |
| 331 | return it.substring(5); |
| 332 | } |
| 333 | |
| 334 | return it; |
| 335 | } |
| 336 | |
| 337 | assertUnreachable(type); |
| 338 | }; |
| 339 | |
| 340 | export const normalisePGliteUrl = ( |
| 341 | it: string, |
no test coverage detected