Skip to content

Commit

Permalink
fix: DCL item upsert url (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Jan 12, 2022
1 parent 2fdc7b1 commit c5a6c1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Item/Item.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ describe('Item router', () => {

describe('and the item is a DCL item', () => {
beforeEach(() => {
itemToUpsert = { ...itemToUpsert, urn: null }
itemToUpsert = { ...itemToUpsert, urn }
collectionMock = {
...collectionMock,
urn_suffix: null,
Expand Down
11 changes: 8 additions & 3 deletions src/Item/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export function getDecentralandItemURN(
export function toDBItem(item: FullItem): ItemAttributes {
const attributes = {
...item,
urn_suffix: item.urn
? decodeThirdPartyItemURN(item.urn).item_urn_suffix
: null,
urn_suffix:
item.urn && isTPItemURN(item.urn)
? decodeThirdPartyItemURN(item.urn).item_urn_suffix
: null,
}
return utils.omit(attributes, [
'urn',
Expand Down Expand Up @@ -66,6 +67,10 @@ export function decodeThirdPartyItemURN(
}
}

export function isTPItemURN(itemURN: string): boolean {
return tpwItemURNRegex.test(itemURN)
}

// TODO: @TPW: implement this
export function getMergedItem(_id: string): Promise<FullItem> {
return {} as any
Expand Down

0 comments on commit c5a6c1b

Please sign in to comment.