Skip to content

Commit 78b9b1c

Browse files
committed
make sure that it works with case-insensitive ids
1 parent 4e7a9bc commit 78b9b1c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

app/serializers/application.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ export default class Application extends JSONAPISerializer {
55
@service
66
metaStore;
77

8+
extractId(_, hash) {
9+
return hash.id.toLowerCase();
10+
}
11+
12+
extractRelationship(relationship) {
13+
// for some reason we only need to update the id to lowercase when it's an object relationship and not an array 🤷
14+
if (relationship?.data?.id) {
15+
relationship.data.id = relationship.data.id.toLowerCase();
16+
}
17+
return super.extractRelationship(relationship);
18+
}
19+
820
normalizeFindRecordResponse(store, primaryModelClass, payload, id) {
921
let normalizedDocument = super.normalizeFindRecordResponse(...arguments);
1022

app/services/meta-store.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ export default class MetaStoreService extends Service {
2323

2424
getRevId(project, version, type, id) {
2525
let encodedId = id;
26-
return this.projectRevMap[`${project}-${version}`][type][encodedId];
26+
let revType = this.projectRevMap[`${project}-${version}`][type];
27+
28+
let matchingKey = Object.keys(revType).find(
29+
(key) => key.toLowerCase() === encodedId.toLowerCase()
30+
);
31+
32+
return this.projectRevMap[`${project}-${version}`][type][matchingKey];
2733
}
2834

2935
getEncodedModulesFromProjectRev(id) {

0 commit comments

Comments
 (0)