diff --git a/src/editors/sharedComponents/TinyMceWidget/hooks.js b/src/editors/sharedComponents/TinyMceWidget/hooks.js index f1c11b850..e97492e55 100644 --- a/src/editors/sharedComponents/TinyMceWidget/hooks.js +++ b/src/editors/sharedComponents/TinyMceWidget/hooks.js @@ -408,9 +408,9 @@ export const setAssetToStaticUrl = ({ editorValue, lmsEndpointUrl }) => { const assetSrcs = typeof content === 'string' ? content.split(/(src="|src="|href="|href=")/g) : []; assetSrcs.filter(src => src.startsWith('/asset')).forEach(src => { let nameFromEditorSrc; - if (src.match(/\/assets\/.+\/asset-v1:\S+[+]\S+[@]\S+[+]\S+\//)?.length >= 1) { + if (src.match(/\/asset-v1:\S+[+]\S+[@]\S+[+]\S+\/\w/)?.length >= 1) { const assetBlockName = src.substring(0, src.search(/("|")/)); - const dividedSrc = assetBlockName.split(/\/assets\/.+\/asset-v1:\S+[+]\S+[@]\S+[+]\S+\//); + const dividedSrc = assetBlockName.split(/\/asset-v1:\S+[+]\S+[@]\S+[+]\S+\//); [, nameFromEditorSrc] = dividedSrc; } else { const assetBlockName = src.substring(src.indexOf('@') + 1, src.search(/("|")/)); diff --git a/src/editors/sharedComponents/TinyMceWidget/hooks.test.js b/src/editors/sharedComponents/TinyMceWidget/hooks.test.js index 525925c1f..484a4b2fe 100644 --- a/src/editors/sharedComponents/TinyMceWidget/hooks.test.js +++ b/src/editors/sharedComponents/TinyMceWidget/hooks.test.js @@ -63,6 +63,7 @@ const mockEditorContentHtml = `
`; +const baseAssetUrl = 'asset-v1:org+test+run+type@asset+block'; const mockImagesRef = { current: [mockImage] }; @@ -182,17 +183,17 @@ describe('TinyMceEditor hooks', () => { }); describe('replaceStaticWithAsset', () => { - const initialContent = '
test
';
+ const initialContent = `
test
`;
const learningContextId = 'course-v1:org+test+run';
const lmsEndpointUrl = 'sOmEvaLue.cOm';
it('returns updated src for text editor to update content', () => {
- const expected = '
test
';
+ const expected = `
test
`;
const actual = module.replaceStaticWithAsset({ initialContent, learningContextId });
expect(actual).toEqual(expected);
});
it('returns updated src with absolute url for expandable editor to update content', () => {
const editorType = 'expandable';
- const expected = `
test
`;
+ const expected = `
test
`;
const actual = module.replaceStaticWithAsset({
initialContent,
editorType,
@@ -209,7 +210,7 @@ describe('TinyMceEditor hooks', () => {
});
describe('setAssetToStaticUrl', () => {
it('returns content with updated img links', () => {
- const editorValue = '