@dhyasama/totem-models 6.21.7 → 6.21.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.npmignore ADDED
@@ -0,0 +1,14 @@
1
+ lib-cov
2
+ *.seed
3
+ *.log
4
+ *.csv
5
+ *.dat
6
+ *.out
7
+ *.pid
8
+ *.gz
9
+
10
+ npm-debug.log
11
+ node_modules
12
+
13
+ .DS_Store
14
+ .idea
@@ -1305,39 +1305,7 @@ module.exports = function(mongoose, config) {
1305
1305
 
1306
1306
  if (!value) { return cb(new Error('value must be provided'), null); }
1307
1307
 
1308
- var getUsername = function getUsername(val) {
1309
-
1310
- if (!val) { return ''; }
1311
- if (val.indexOf('@') === 0) { val = val.replace('@', ''); }
1312
-
1313
- var username = '';
1314
- var usernameRegExp = new RegExp("^[A-Za-z0-9_.@]{3,}$");
1315
- var usernameMatch = [];
1316
- var URL = require('url');
1317
- var parsedUrl = URL.parse(val);
1318
- var protocol = parsedUrl.protocol;
1319
-
1320
- if (!protocol) { parsedUrl = URL.parse('http://' + val); }
1321
-
1322
- var pathname = parsedUrl.pathname;
1323
-
1324
- if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
1325
- if (pathname.indexOf('company/') === 0) { pathname = pathname.replace('company/', ''); }
1326
- if (pathname.indexOf('organization/') === 0) { pathname = pathname.replace('organization/', ''); }
1327
- if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
1328
-
1329
- if (pathname) { usernameMatch = usernameRegExp.exec(pathname); }
1330
- else { usernameMatch = usernameRegExp.exec(val); }
1331
-
1332
- if (!_.isEmpty(usernameMatch)) { username = usernameMatch[0]; }
1333
-
1334
- console.log('Username:', val, '-->', username);
1335
-
1336
- return username;
1337
-
1338
- };
1339
-
1340
- var username = getUsername(value);
1308
+ var username = utils.getUsernameFromUrl(value);
1341
1309
 
1342
1310
  if (!username) { return cb(null, []); }
1343
1311
 
package/lib/Person.js CHANGED
@@ -714,38 +714,7 @@ module.exports = function(mongoose, config) {
714
714
 
715
715
  if (!value) { return cb(new Error('value must be provided'), null); }
716
716
 
717
- var getUsername = function getUsername(val) {
718
-
719
- if (!val) { return ''; }
720
- if (val.indexOf('@') === 0) { val = val.replace('@', ''); }
721
-
722
- var username = '';
723
- var usernameRegExp = new RegExp("^[A-Za-z0-9_.@]{3,}$");
724
- var usernameMatch = [];
725
- var URL = require('url');
726
- var parsedUrl = URL.parse(val);
727
- var protocol = parsedUrl.protocol;
728
-
729
- if (!protocol) { parsedUrl = URL.parse('http://' + val); }
730
-
731
- var pathname = parsedUrl.pathname;
732
-
733
- if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
734
- if (pathname.indexOf('in/') === 0) { pathname = pathname.replace('in/', ''); }
735
- if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
736
-
737
- if (pathname) { usernameMatch = usernameRegExp.exec(pathname); }
738
- else { usernameMatch = usernameRegExp.exec(val); }
739
-
740
- if (!_.isEmpty(usernameMatch)) { username = usernameMatch[0]; }
741
-
742
- console.log('Username:', val, '-->', username);
743
-
744
- return username;
745
-
746
- };
747
-
748
- var username = getUsername(value);
717
+ var username = utils.getUsernameFromUrl(value);
749
718
 
750
719
  if (!username) { return cb(null, []); }
751
720