UNPKG

@tvkitchen/countertop

Version:

The entry point for developers who want to set up a TV Kitchen.

21 lines (17 loc) 627 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeTopic = void 0; /* eslint-disable import/prefer-default-export */ /** * Correct a kafka topic string so it meets the documented conditions for kafka topics. * * This will replace any invalid character with a '-' * This will truncate any string longer than 255 characters. * * @param {String} topic The topic string to be sanitized. * @return {String} The sanitized topic string. */ const sanitizeTopic = topic => topic.replace(/[^a-zA-Z0-9\\._\\-]/g, '-').substring(0, 255); exports.sanitizeTopic = sanitizeTopic;