gkucmierz / social-links

Validate & sanitize social links

Home Page:https://npmjs.com/package/social-links

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot add a new profile

revivalme opened this issue · comments

commented

I'm trying to add a new discord profile, but get an error
Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).findIndex is not a function

const { SocialLinks, TYPE_DESKTOP } = require("social-links");

const socialLinks = new SocialLinks();

const discordProfile = {
  name: "discord",
  matches: [
    {
      match: "(https?://)?(www.)?discord.gg/({GENERATED})",
      group: 3,
      pattern: "https://discord.gg/{GENERATED}",
      type: TYPE_DESKTOP
    },
    { match: "({GENERATED})", group: 1 }
  ]
};

socialLinks.addProfile("discord", discordProfile);

const res = socialLinks.isValid("discord", "https://discord.gg/mTpXg2mr");

console.log(res);

Demo: https://codesandbox.io/s/frosty-spence-kosd3

const discordProfileMatches = [
  {
    match: "(https?://)?(www.)?discord.gg/({PROFILE_ID})",
    group: 3,
    pattern: "https://discord.gg/{PROFILE_ID}",
    type: TYPE_DESKTOP
  },
  { match: "({PROFILE_ID})", group: 1 }
];

socialLinks.addProfile("discord", discordProfileMatches);

Try to add matches array only.

https://codesandbox.io/s/nostalgic-night-4mq1g

It needs to be clarified in README.