(url, init)
| 63 | } |
| 64 | |
| 65 | export function projectScopedUrl(url, init) { |
| 66 | if (!selectedProjectId || typeof url !== "string" || !url.startsWith("/")) return url; |
| 67 | if ( |
| 68 | !isScopedApiUrl(url, "/api/plugins") && |
| 69 | !isScopedApiUrl(url, "/api/automation") && |
| 70 | !isScopedApiUrl(url, "/api/capabilities") && |
| 71 | !isScopedApiUrl(url, "/api/settings") |
| 72 | ) { |
| 73 | return url; |
| 74 | } |
| 75 | return `/api/projects/${encodeURIComponent(selectedProjectId)}${url.slice("/api".length)}`; |
| 76 | } |
| 77 | |
| 78 | export function authedFetch(url, init) { |
| 79 | return fetch(projectScopedUrl(url, init), init); |
no test coverage detected