mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 12:53:32 +00:00
allow https
This commit is contained in:
@@ -85,13 +85,13 @@ export class HttpIntegration implements IIntegration<HttpSubscriptionOptions> {
|
||||
const parsedMessage = parseTemplateNested(message, state || {});
|
||||
try {
|
||||
const parsedUrl = new globalThis.URL(parsedMessage);
|
||||
if (parsedUrl.protocol != 'http:') {
|
||||
logger.error(LogOrigin.Tx, `HTTP Integration: Only HTTP allowed, got ${parsedUrl.protocol}`);
|
||||
return {
|
||||
success: false,
|
||||
message: `Only HTTP allowed, got ${parsedUrl.protocol}`,
|
||||
};
|
||||
}
|
||||
// if (parsedUrl.protocol != 'http:') {
|
||||
// logger.error(LogOrigin.Tx, `HTTP Integration: Only HTTP allowed, got ${parsedUrl.protocol}`);
|
||||
// return {
|
||||
// success: false,
|
||||
// message: `Only HTTP allowed, got ${parsedUrl.protocol}`,
|
||||
// };
|
||||
// }
|
||||
this.emit(parsedUrl);
|
||||
} catch (err) {
|
||||
logger.error(LogOrigin.Tx, `HTTP Integration: ${err}`);
|
||||
|
||||
@@ -81,21 +81,22 @@ describe('validateHttpSubscriptionCycle()', () => {
|
||||
it('should return false when given an HttpSubscription with an invalid property value', () => {
|
||||
const invalidBoolean = [{ message: 'http://', enabled: 'not a boolean' }];
|
||||
const invalidHttp = [{ message: 'test', enabled: true }];
|
||||
const noHttps = [{ message: 'https://test', enabled: true }];
|
||||
const noFtp = [{ message: 'ftp://test', enabled: true }];
|
||||
const noEmpty = [{ message: '', enabled: true }];
|
||||
|
||||
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
||||
expect(validateHttpSubscriptionCycle(invalidBoolean)).toBe(false);
|
||||
|
||||
expect(validateHttpSubscriptionCycle(invalidHttp)).toBe(false);
|
||||
expect(validateHttpSubscriptionCycle(noHttps)).toBe(false);
|
||||
expect(validateHttpSubscriptionCycle(noFtp)).toBe(false);
|
||||
expect(validateHttpSubscriptionCycle(noEmpty)).toBe(false);
|
||||
});
|
||||
it('should return true when given an HttpSubscription matches definition', () => {
|
||||
const validHttp = [{ message: 'http://', enabled: true }];
|
||||
const validHttps = [{ message: 'https://', enabled: true }];
|
||||
|
||||
const result = validateHttpSubscriptionCycle(validHttp);
|
||||
expect(result).toBe(true);
|
||||
expect(validateHttpSubscriptionCycle(validHttp)).toBe(true);
|
||||
expect(validateHttpSubscriptionCycle(validHttps)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -227,7 +227,8 @@ export const parseOsc = (data: { osc?: Partial<OSCSettings> }): OSCSettings => {
|
||||
*/
|
||||
export const validateHttpSubscriptionCycle = (data: HttpSubscriptionOptions[]): boolean => {
|
||||
for (const subscriptionOption of data) {
|
||||
const isHttp = subscriptionOption.message?.startsWith('http://');
|
||||
const isHttp =
|
||||
subscriptionOption.message?.startsWith('http://') || subscriptionOption.message?.startsWith('https://');
|
||||
if (typeof subscriptionOption.message !== 'string' || !isHttp || typeof subscriptionOption.enabled !== 'boolean') {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user