New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

social-links

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

social-links - npm Package Compare versions

Comparing version 1.6.1 to 1.7.0

6

lib/main.d.ts

@@ -14,2 +14,6 @@ import { PREDEFINED_PROFILES } from './profiles/';

}
export interface Score {
profileName: string;
score: number;
}
export interface Config {

@@ -34,3 +38,5 @@ usePredefinedProfiles?: boolean;

getProfileNames(): Array<string>;
scoreProfiles(link: string): Array<Score>;
detectProfile(link: string): string;
}
//# sourceMappingURL=main.d.ts.map

@@ -146,2 +146,22 @@ "use strict";

};
// list all matching profiles sorted by score
SocialLinks.prototype.scoreProfiles = function (link) {
var _this = this;
return this.getProfileNames().map(function (profileName) {
var matches = _this.profiles.get(profileName);
var score = (matches || []).reduce(function (sum, match) {
return sum + (createRegexp(match, _this.config).test(link) ? 1 : 0);
}, 0);
return { profileName: profileName, score: score };
})
.filter(function (obj) { return obj.score > 0; })
.sort(function (a, b) { return b.score - a.score; });
};
// return first matching profile
SocialLinks.prototype.detectProfile = function (link) {
var scores = this.scoreProfiles(link);
if (scores.length === 0)
return '';
return scores[0].profileName;
};
return SocialLinks;

@@ -148,0 +168,0 @@ }());

@@ -202,3 +202,22 @@ "use strict";

});
describe('detectProfile', function () {
it('should detect github profiles', function () {
expect(sl.detectProfile('https://github.com/gkucmierz')).toEqual('github');
expect(sl.detectProfile('http://github.com/abc')).toEqual('github');
expect(sl.detectProfile('github.com/abc')).toEqual('github');
expect(sl.detectProfile('www.github.com/gkucmierz')).toEqual('github');
});
it('should detect different profiles', function () {
expect(sl.detectProfile('https://exercism.io/profiles/gkucmierz')).toEqual('exercism');
expect(sl.detectProfile('https://dev.to/gkucmierz')).toEqual('dev_to');
expect(sl.detectProfile('https://youtube.com/channel/gkucmierz')).toEqual('youtube');
expect(sl.detectProfile('https://linkedin.com/in/gkucmierz')).toEqual('linkedin');
expect(sl.detectProfile('https://medium.com/@gkucmierz')).toEqual('medium');
});
it('should return empty string if no match', function () {
expect(sl.detectProfile('https://www.codewars.com/kata/my-languages')).toEqual('');
expect(sl.detectProfile('')).toEqual('');
});
});
});
//# sourceMappingURL=main.spec.js.map

2

package.json
{
"name": "social-links",
"version": "1.6.1",
"version": "1.7.0",
"description": "Validate & sanitize social links",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc