Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/metal-rooms-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/contact": patch
---

Do not throw an Error when using a contact with no 'name' property
8 changes: 6 additions & 2 deletions workspaces/contact/src/UnlitContact.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ export class UnlitContact {

public dependencies = new Set<string>();

constructor(contact: Contact) {
constructor(
contact: Contact
) {
this.illuminated = structuredClone(contact);
this.extendedName = utils.parseRegExp(contact.name);
this.extendedName = typeof contact.name === "string" ?
utils.parseRegExp(contact.name) :
null;
}

compareTo(
Expand Down
15 changes: 15 additions & 0 deletions workspaces/contact/test/ContactExtractor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ import {
} from "../src/index.js";

describe("ContactExtractor", () => {
test("Given a contact with no name, it should not throw an Error", () => {
const highlighted: any = {
email: "foobar@gmail.com"
};
const extractor = new ContactExtractor({
highlight: [highlighted]
});

const dependencies: Record<string, ContactExtractorPackageMetadata> = {
random: fakePackageMetadata()
};

extractor.fromDependencies(dependencies);
});

describe("fromDependencies", () => {
test(`Given three dependencies where the Highlighted Contact appears two times,
it should successfully scan, extract, and return the contact along with the list of dependencies where it appears.`, () => {
Expand Down