Skip to content

Update utils.go #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/modules/linkedin/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,23 @@ func (options *Options) getPeople(companyID, start int) []string {
}
// Parse the name to output in the specified format
name := strings.Split(people.Title.Text, " ")
// If the name is composed of more than 2 words or the email should not be guessed, we skip it
if len(name) == 2 && options.Email {
// If the name is composed of less than 2 words or the email should not be guessed, we skip it
if len(name) >= 2 && options.Email {
var email string
var last string
email = options.Format
last = strings.TrimRight(name[1], ",")
log.Verbose(name[0] + " - " + name[1])
email = strings.ReplaceAll(email, "{first}", name[0])
email = strings.ReplaceAll(email, "{f}", name[0][0:1])
email = strings.ReplaceAll(email, "{last}", name[1])
email = strings.ReplaceAll(email, "{l}", name[1][0:1])
email = strings.ReplaceAll(email, "{last}", last)
email = strings.ReplaceAll(email, "{l}", last[0:1])
email = strings.ReplaceAll(email, "{l2}", last[0:2])
email = strings.ToLower(unidecode.Unidecode(email))
log.Success(email + " - " + people.PrimarySubtitle.Text + " - " + people.SecondarySubtitle.Text)
output = append(output, email)
}

if !options.Email {
result := people.Title.Text + " - " + people.PrimarySubtitle.Text + " - " + people.SecondarySubtitle.Text
log.Success(result)
Expand Down