Skip to content

Commit

Permalink
Merge pull request #5 from customeros/adjust-validation-for-add-contacts
Browse files Browse the repository at this point in the history
change linkedin validation for add contacts + add linkedin url
  • Loading branch information
jontyk authored Feb 18, 2025
2 parents 3b358ec + c70c706 commit 0709c6a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class LinkedIn {
} else {
this.emptyLinkedInUrl = false;

const linkedInUrlPattern = /^(https?:\/\/)?(www\.)?linkedin\.com\/.*$/;
const linkedInUrlPattern = /linkedin\.com\/in\/[^/]+\/?$/;

if (!linkedInUrlPattern.test(url)) {
this.invalidLinkedInUrl = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class CreateContactUsecase {
@observable static accessor isBrowserExtensionEnabled: boolean = true;

private readonly PATTERNS = {
linkedin: /linkedin\.com\/in\/[^/]+$/,
linkedin: /linkedin\.com\/in\/[^/]+\/?$/,
email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
};

Expand Down Expand Up @@ -168,6 +168,8 @@ export class CreateContactUsecase {
this.inputValue = '';
this.isLoading = false;
this.type = 'linkedin';
this.root.ui.commandMenu.toggle('AddSingleContact');
this.root.ui.commandMenu.clearContext();
}

@action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const AddSingleContact = observer(() => {
: usecase.currentError.message
? usecase.currentError.message
: usecase.currentError.isInvalid
? `Invalid ${usecase.type} format`
? `This ${usecase.type} seems to be incorrect`
: ''}
</p>

Expand Down
3 changes: 1 addition & 2 deletions src/utils/linkedinValidation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export function validLinkedInProfileUrl(url: string): boolean {
const re =
/(https?:\/\/(www\.)|(www\.))?linkedin\.com\/(mwlite\/|m\/)?in\/[a-zA-Z0-9-]+\/?$/;
const re = /linkedin\.com\/in\/[^/]+\/?$/;

return re.test(url);
}

0 comments on commit 0709c6a

Please sign in to comment.