Skip to content

Instantly share code, notes, and snippets.

@heysmmprovider
Created October 10, 2024 19:45
Show Gist options
  • Select an option

  • Save heysmmprovider/35710d5150facb2c79d84899aa926250 to your computer and use it in GitHub Desktop.

Select an option

Save heysmmprovider/35710d5150facb2c79d84899aa926250 to your computer and use it in GitHub Desktop.
Instagram Channel Link Serializer for SMM: This Node.js utility function is designed to streamline social media marketing efforts by extracting the unique identifier from various Instagram channel URLs. It supports multiple URL patterns to accommodate different link formats used in Instagram channel invites. This functionality is crucial for aut…
// Instagram Channel Link Serializer for SMM:
// This Node.js utility function is designed to streamline social media marketing efforts by extracting the unique identifier from various Instagram channel URLs.
// It supports multiple URL patterns to accommodate different link formats used in Instagram channel invites. This functionality is crucial for automating the process of joining channels, simplifying user redirection, and enhancing channel management tasks in SMM tools.
// The utility also includes robust error handling for incorrect URL formats, ensuring reliability in SMM workflows.
exports.serializeChannelLink = (link) => {
const prefixes = ["https://ig.me/j/", "https://www.instagram.com/j/", "https://www.instagram.com/channel/"];
let code = null;
for (const prefix of prefixes) {
if (link.startsWith(prefix)) {
code = link.slice(prefix.length);
if (code.endsWith('/')) code = code.slice(0, -1);
break;
}
}
if (!code) return "Wrong Link for Channel";
return code;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment