Skip to content

Fix AICC identifier regex #979

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

Merged
merged 1 commit into from
May 27, 2025
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
6 changes: 5 additions & 1 deletion src/constants/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export const scorm12_regex = {
export const aicc_regex = {
...scorm12_regex,
...{
CMIIdentifier: "^\\w{1,255}$",
// AICC identifiers may contain letters, numbers, underscores,
// periods, and hyphens up to 255 characters in length.
// The previous expression only allowed "\w" characters which
// excluded periods and hyphens.
CMIIdentifier: "^[A-Za-z0-9._-]{1,255}$",
},
};
export const scorm2004_regex = {
Expand Down
6 changes: 6 additions & 0 deletions test/cmi/aicc_cmi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ describe("AICC CMI Tests", () => {
cmi: cmi(),
fieldName: "cmi.core.student_id",
});
it("should allow hyphens and periods in student_id", () => {
const instance = cmi();
expect(() => {
instance.core.student_id = "student-1.id";
}).not.toThrow();
});
h.checkReadAndWrite({
cmi: cmi(),
fieldName: "cmi.core.student_name",
Expand Down