Skip to content

Commit

Permalink
fix(images): Fallback as custom image when splitting OS from resource…
Browse files Browse the repository at this point in the history
… name (#5581)
  • Loading branch information
abuyukyi101198 authored Jan 21, 2025
1 parent fd0da3f commit c7d6f7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/app/store/bootresource/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ describe("bootresource utils", () => {
os: "centos",
release: "centos70",
});
expect(splitResourceName("ubuntu")).toStrictEqual({
os: "",
release: "",
expect(splitResourceName("rocky9")).toStrictEqual({
os: "other",
release: "rocky9",
});
expect(splitResourceName("ubuntu/focal/amd64/generic")).toStrictEqual({
os: "",
release: "",
os: "ubuntu",
release: "focal",
});
expect(splitResourceName("")).toStrictEqual({ os: "", release: "" });
});
Expand Down
7 changes: 5 additions & 2 deletions src/app/store/bootresource/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ export const splitResourceName = (
name: BootResource["name"]
): { os: string; release: string } => {
const split = name.split("/");
return split.length === 2
if (name.length === 0) {
return { os: "", release: "" };
}
return split.length > 1
? { os: split[0], release: split[1] }
: { os: "", release: "" };
: { os: "other", release: name };
};

export const splitImageName = (
Expand Down

0 comments on commit c7d6f7c

Please sign in to comment.