diff --git a/package-lock.json b/package-lock.json index 0bd8284f2..ba2af872f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10038,9 +10038,9 @@ "dev": true }, "node_modules/fast-xml-parser": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.2.tgz", - "integrity": "sha512-DLzIPtQqmvmdq3VUKR7T6omPK/VCRNqgFlGtbESfyhcH2R4I8EzK1/K6E8PkRCK2EabWrUHK32NjYRbEFnnz0Q==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.4.tgz", + "integrity": "sha512-fbfMDvgBNIdDJLdLOwacjFAPYt67tr31H9ZhWSm45CDAxvd0I6WTlSOUo7K2P/K5sA5JgMKG64PI3DMcaFdWpQ==", "funding": [ { "type": "paypal", diff --git a/src/editors/data/services/cms/urls.js b/src/editors/data/services/cms/urls.js index e3c7402eb..337129f7e 100644 --- a/src/editors/data/services/cms/urls.js +++ b/src/editors/data/services/cms/urls.js @@ -16,7 +16,9 @@ export const returnUrl = ({ studioEndpointUrl, unitUrl, learningContextId }) => }; export const block = ({ studioEndpointUrl, blockId }) => ( - `${studioEndpointUrl}/xblock/${blockId}` + blockId.includes('block-v1') + ? `${studioEndpointUrl}/xblock/${blockId}` + : `${studioEndpointUrl}/api/xblock/v2/xblocks/${blockId}` ); export const blockAncestor = ({ studioEndpointUrl, blockId }) => ( diff --git a/src/editors/data/services/cms/urls.test.js b/src/editors/data/services/cms/urls.test.js index a389ae008..27ebcd963 100644 --- a/src/editors/data/services/cms/urls.test.js +++ b/src/editors/data/services/cms/urls.test.js @@ -21,7 +21,8 @@ import { describe('cms url methods', () => { const studioEndpointUrl = 'urLgoeStOstudiO'; - const blockId = 'blOckIDTeST123'; + const blockId = 'block-v1-blOckIDTeST123'; + const v2BlockId = 'blOckIDTeST123'; const learningContextId = 'lEarnIngCOntextId123'; const courseId = 'course-v1:courseId123'; const libraryV1Id = 'library-v1:libaryId123'; @@ -62,10 +63,14 @@ describe('cms url methods', () => { }); }); describe('block', () => { - it('returns url with studioEndpointUrl and blockId', () => { + it('returns v1 url with studioEndpointUrl and blockId', () => { expect(block({ studioEndpointUrl, blockId })) .toEqual(`${studioEndpointUrl}/xblock/${blockId}`); }); + it('returns v2 url with studioEndpointUrl and v2BlockId', () => { + expect(block({ studioEndpointUrl, blockId: v2BlockId })) + .toEqual(`${studioEndpointUrl}/api/xblock/v2/xblocks/${v2BlockId}`); + }); }); describe('blockAncestor', () => { it('returns url with studioEndpointUrl, blockId and ancestor query', () => {