| 1 |
import { trimTrailingChar } from './text' |
| 2 |
import type { AxiosRequestConfig } from 'axios' |
| 3 |
|
| 4 |
const normalizeUrl = (url: string | undefined) => |
| 5 |
trimTrailingChar(url ?? '', '/') |
| 6 |
|
| 7 |
export const REST_BASES = { |
| 8 |
snippets: normalizeUrl(window.CODE_SNIPPETS?.restAPI.snippets), |
| 9 |
recentlyActive: normalizeUrl(window.CODE_SNIPPETS?.restAPI.recentlyActive), |
| 10 |
preferences: normalizeUrl(window.CODE_SNIPPETS?.restAPI.preferences), |
| 11 |
importPlugins: normalizeUrl(window.CODE_SNIPPETS?.restAPI.importPlugins), |
| 12 |
importFiles: normalizeUrl(window.CODE_SNIPPETS?.restAPI.importFiles), |
| 13 |
cloud: { |
| 14 |
snippets: normalizeUrl(window.CODE_SNIPPETS?.restAPI.cloud.snippets), |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
export const REST_API_AXIOS_CONFIG: AxiosRequestConfig = { |
| 19 |
headers: { |
| 20 |
'X-WP-Nonce': window.CODE_SNIPPETS?.restAPI.nonce, |
| 21 |
'Access-Control': window.CODE_SNIPPETS?.restAPI.cloud.token |
| 22 |
} |
| 23 |
} |
| 24 |
|