Replace axios with fetch
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
||||
|
||||
import type { Location } from 'soapbox/types/history';
|
||||
|
||||
const LOCAL_STORAGE_REDIRECT_KEY = 'soapbox:redirect-uri';
|
||||
const LOCAL_STORAGE_REDIRECT_KEY = 'plfe:redirect-uri';
|
||||
|
||||
const cacheCurrentUrl = (location: Location) => {
|
||||
const actualUrl = encodeURIComponent(`${location.pathname}${location.search}`);
|
||||
|
||||
@ -22,7 +22,7 @@ export const federationRestrictionsDisclosed = (state: RootState): boolean => {
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine whether Soapbox is running in standalone mode.
|
||||
* Determine whether pl-fe is running in standalone mode.
|
||||
* Standalone mode runs separately from any backend and can login anywhere.
|
||||
*/
|
||||
export const isStandalone = (state: RootState): boolean => {
|
||||
|
||||
23
src/utils/url.ts
Normal file
23
src/utils/url.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import queryString from 'query-string';
|
||||
|
||||
// Adapted from Axios https://github.com/axios/axios/blob/v1.x/lib/core/buildFullPath.js
|
||||
const isAbsoluteURL = (url: string) => /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||
|
||||
const combineURLs = (baseURL: string, relativeURL: string) => relativeURL
|
||||
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
||||
: baseURL;
|
||||
|
||||
const buildFullPath = (requestedURL: string, baseURL?: string, params?: Record<string, any>) => {
|
||||
const path = (baseURL && !isAbsoluteURL(requestedURL)) ? combineURLs(baseURL, requestedURL) : requestedURL;
|
||||
|
||||
if (params) {
|
||||
return `${path}?${queryString.stringify(params, { arrayFormat: 'bracket' })}`;
|
||||
}
|
||||
return path;
|
||||
};
|
||||
|
||||
export {
|
||||
isAbsoluteURL,
|
||||
combineURLs,
|
||||
buildFullPath,
|
||||
};
|
||||
Reference in New Issue
Block a user