(win: Window)
| 55 | }; |
| 56 | |
| 57 | export const configFromURL = (win: Window) => { |
| 58 | const configObj: any = {}; |
| 59 | win.location.search |
| 60 | .slice(1) |
| 61 | .split('&') |
| 62 | .map((entry) => entry.split('=')) |
| 63 | .map(([key, value]) => { |
| 64 | try { |
| 65 | return [decodeURIComponent(key), decodeURIComponent(value)]; |
| 66 | } catch (e) { |
| 67 | return ['', '']; |
| 68 | } |
| 69 | }) |
| 70 | .filter(([key]) => startsWith(key, IONIC_PREFIX)) |
| 71 | .map(([key, value]) => [key.slice(IONIC_PREFIX.length), value]) |
| 72 | .forEach(([key, value]) => { |
| 73 | configObj[key] = value; |
| 74 | }); |
| 75 | |
| 76 | return configObj; |
| 77 | }; |
| 78 | |
| 79 | const startsWith = (input: string, search: string): boolean => { |
| 80 | return input.substr(0, search.length) === search; |
no test coverage detected