Skip to content

Commit

Permalink
Document findAccessManifestationByIdentifier in reservation modal helper
Browse files Browse the repository at this point in the history
This function compares ISBN identifiers, which can have different
formats, some including spaces, and/or dashes, or without them
altogether. Because of this, we remove all non-digit characters first
before making a comparison.
  • Loading branch information
Adamik10 committed Nov 14, 2023
1 parent 73b7a65 commit b4be81f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/apps/reservation-list/modal/reservation-details/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ type AccessManifestations =
export const findAccessManifestationByIdentifier = (
manifestations: AccessManifestations,
identifier: string
) => {
return manifestations.filter((manifestation) =>
) =>
manifestations.filter((manifestation) =>
manifestation.identifiers.find(
// We are comparing ISBNs here, which can have different formats -
// with spaces/dashes, so we remove all non-digits before comparing.
(id) => id.value.replace(/\D/g, "") === identifier.replace(/\D/g, "")
)
);
};

export const findEreolAccessLinkFromManifestations = (
manifestations: AccessManifestations
Expand Down

0 comments on commit b4be81f

Please sign in to comment.