verdnatura-chat/app/lib/methods/helpers/addProtocol.ts

11 lines
381 B
TypeScript
Raw Normal View History

2023-03-01 15:11:02 +00:00
// If the link does not have the protocol at the beginning, we are inserting https as the default,
// since by conversion the most used is the secure protocol, with the same behavior as the web.
2023-02-15 14:26:53 +00:00
const addProtocol = (url: string): string => {
if (!url.toLowerCase().startsWith('http')) {
return `https://${url.replace('//', '')}`;
}
return url;
};
export default addProtocol;