gkucmierz/social-links

detect links only w/o profiles

Opened this issue · 2 comments

Hi! I'm wondering if it's possible to detect social links only, not profiles. For example:

const detectSocialLink = (url: string) =>
  networks.reduce<[network: typeof networks[number] | 'url', url: string]>(
    (prev, network) => {
      try {
        if (socialLinks.isValid(network, url)) {
          return [network, socialLinks.sanitize(network, url)];
        }
      } catch (err) {
        return prev;
      }

      return prev;
    },
    ['url', url],
  );


expect(detectSocialLink('https://instagram.com/vinspee')).toBe(['instagram', 'https://instagram.com/vinspee'])
expect(detectSocialLink('vinspee').toBe(['url', 'vinspee'])

i'd like to take user input and determine which network was detected. When "profile" names match, essentially everything becomes a match until it looks like a URL.

Good point.

I added detectProfile in v1.7.0

I can also automatically detect profile in following functions when profileName is omitted.
getProfileId
getLink
isValid
sanitize

What do you think about this @VinSpee ?

I think that nails it. Looks good! Thanks.