Skip to content

Commit

Permalink
Merge pull request #2216 from metriport/master
Browse files Browse the repository at this point in the history
BACKMERGE
  • Loading branch information
Orta21 committed Jun 6, 2024
2 parents eb6bae1 + bf2890a commit 2520398
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function parseDocumentReference(
const documentReference: DocumentReference = {
homeCommunityId: getHomeCommunityIdForDr(outboundRequest, extrinsicObject),
repositoryUniqueId,
docUniqueId,
docUniqueId: stripUrnPrefix(docUniqueId),
contentType: extrinsicObject?._mimeType,
language: findSlotValue("languageCode"),
size: sizeValue ? parseInt(sizeValue) : undefined,
Expand Down
36 changes: 36 additions & 0 deletions packages/core/src/util/__tests__/urn.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { stripUrnPrefix } from "../urn";

beforeEach(() => {
jest.restoreAllMocks();
});

describe("stripUrnPrefix", () => {
it("returns empty string when gets undefined", async () => {
const res = stripUrnPrefix(undefined);
expect(res).toEqual("");
});

it("returns string when gets number", async () => {
const original = 123;
const res = stripUrnPrefix(original);
expect(res).toEqual("123");
});

it("returns stripped string when gets urn:oid", async () => {
const original = "urn:oid:2.16.840.1.113883.3.9621";
const res = stripUrnPrefix(original);
expect(res).toEqual("2.16.840.1.113883.3.9621");
});

it("returns stripped string when gets urn:uuid", async () => {
const original = "urn:uuid:2.16.840.1.113883.3.9621";
const res = stripUrnPrefix(original);
expect(res).toEqual("2.16.840.1.113883.3.9621");
});

it("returns string when its a normal oid", async () => {
const original = "2.16.840.1.113883.3.9621";
const res = stripUrnPrefix(original);
expect(res).toEqual("2.16.840.1.113883.3.9621");
});
});
2 changes: 1 addition & 1 deletion packages/core/src/util/urn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const urnRegex = /^urn:oid:/;
const urnRegex = /^urn:(oid|uuid):/;

export function wrapIdInUrnUuid(id: string): string {
return `urn:uuid:${id}`;
Expand Down

0 comments on commit 2520398

Please sign in to comment.