@polls-platform/core
Version:
Polls Platform core library
22 lines (21 loc) • 813 B
JavaScript
;
/* ********************************************************* */
// region: Utils
/* ********************************************************* */
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsePollUrl = void 0;
// TODO: this is bad idea, the URL could change
function parsePollUrl({ pollUrl }) {
const parsedUrl = new URL(pollUrl);
const pathParts = parsedUrl.pathname.split('/').filter((part) => part !== '');
if (pathParts.length < 2 || (pathParts[0] !== 'polls' && pathParts[0] !== 'poll-drafts')) {
// URL does not have the expected structure
return null;
}
const pollId = pathParts[1]; // pollId should be the second part of the path
return {
pollId: pollId,
};
}
exports.parsePollUrl = parsePollUrl;
// endregion