()
| 3 | type CacheType = 'localStorage' | 'sessionStorage' |
| 4 | |
| 5 | const getPathPrefix = () => { |
| 6 | const pathname = window.location.pathname |
| 7 | // eslint-disable-next-line no-useless-escape |
| 8 | const match = pathname.match(/^\/([^\/]+)/) |
| 9 | return match ? `${match[1]}_` : 'sqlbot_v1_' |
| 10 | } |
| 11 | |
| 12 | export const useCache = (type: CacheType = 'localStorage') => { |
| 13 | const originalCache = new WebStorageCache({ storage: type }) |