s4s-packager / src /p4 /url-utils.js
soiz1's picture
Upload 225 files
7aec436 verified
export const extractProjectId = (text) => {
const match = text.match(/\d+/);
if (!match) {
return '';
}
return match[0];
};
export const isValidURL = (str) => {
try {
const url = new URL(str);
return url.protocol === 'http:' || url.protocol === 'https:';
} catch (e) {
return false;
}
};
export const getTitleFromURL = (url) => {
const match = url.match(/\/([^\/]+)\.sb[2|3]?$/);
if (match) {
return match[1];
}
return '';
};