gkucmierz/social-links

Separate `isValid` check for URLs and ProfileId

Closed this issue · 2 comments

I don't believe this was meant to perform this way, but the isValid check returns true whether you use the FQDN or just the profileId.

i.e.: both work

socialLinks.isValid('facebook', 'https://facebook.com/<username>'); // true
socialLinks.isValid('facebook', '<username>'); // true

If this was the desired functionality, I'd say they should be split into isValidProfileId and isValidURL to account for having to manually write a URL regex check.

The idea was that string should match to any match object with regex in order to be valid.
There can also be regex expressions in plain username. For example max 20 chars and only letters.
You can still remove default profiles and add yours.

So this check is only for validating profileIds? The README made it seems like it was meant to validate the full URL but looks like it's just stripping out anything else but the profiled if the beginning part of the URL is correct. If this is the case, then I misunderstood the intent and don't think this would fit my specific use case.