mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
move logic to provider utils
This commit is contained in:
parent
9bea9793ad
commit
84a8b1a419
@ -10,6 +10,7 @@ import type { client, server } from '../../../../types/remote/protocol';
|
||||
import type { ILocalStrapiDestinationProviderOptions } from '../local-destination';
|
||||
import { TRANSFER_PATH } from '../../remote/constants';
|
||||
import { ProviderTransferError, ProviderValidationError } from '../../../errors/providers';
|
||||
import { trimTrailingSlash } from '../../../utils/providers';
|
||||
|
||||
interface ITransferTokenAuth {
|
||||
type: 'token';
|
||||
@ -210,9 +211,8 @@ class RemoteStrapiDestinationProvider implements IDestinationProvider {
|
||||
});
|
||||
}
|
||||
const wsProtocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsUrl = `${wsProtocol}//${url.host}${url.pathname.replace(
|
||||
/\/$/,
|
||||
''
|
||||
const wsUrl = `${wsProtocol}//${url.host}${trimTrailingSlash(
|
||||
url.pathname
|
||||
)}${TRANSFER_PATH}/push`;
|
||||
|
||||
// No auth defined, trying public access for transfer
|
||||
|
||||
@ -16,6 +16,7 @@ import {
|
||||
ProviderTransferError,
|
||||
ProviderValidationError,
|
||||
} from '../../../errors/providers';
|
||||
import { trimTrailingSlash } from '../../../utils/providers';
|
||||
import { TRANSFER_PATH } from '../../remote/constants';
|
||||
import { ILocalStrapiSourceProviderOptions } from '../local-source';
|
||||
import { createDispatcher } from '../utils';
|
||||
@ -227,9 +228,8 @@ class RemoteStrapiSourceProvider implements ISourceProvider {
|
||||
let ws: WebSocket;
|
||||
this.assertValidProtocol(url);
|
||||
const wsProtocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsUrl = `${wsProtocol}//${url.host}${url.pathname.replace(
|
||||
/\/$/,
|
||||
''
|
||||
const wsUrl = `${wsProtocol}//${url.host}${trimTrailingSlash(
|
||||
url.pathname
|
||||
)}${TRANSFER_PATH}/pull`;
|
||||
|
||||
// No auth defined, trying public access for transfer
|
||||
|
||||
@ -10,3 +10,7 @@ export const assertValidStrapi: ValidStrapiAssertion = (strapi?: unknown, msg =
|
||||
throw new ProviderInitializationError(`${msg}. Strapi instance not found.`);
|
||||
}
|
||||
};
|
||||
|
||||
export const trimTrailingSlash = (input: string): string => {
|
||||
return input.replace(/\/$/, '');
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user