diff --git a/app/assets/javascripts/behaviors/markdown/nodes/playable.js b/app/assets/javascripts/behaviors/markdown/nodes/playable.js index 08539df12421bee0ffa6ea299b2452636f181912..9209c69d04a3b4bfb42c8b161bc50d194f4878c8 100644 --- a/app/assets/javascripts/behaviors/markdown/nodes/playable.js +++ b/app/assets/javascripts/behaviors/markdown/nodes/playable.js @@ -42,7 +42,7 @@ export default class Playable extends Node { }, { tag: `${this.mediaType}[src]`, - getAttrs: el => ({ src: el.getAttribute('src'), alt: el.dataset.title }), + getAttrs: el => ({ src: el.src, alt: el.dataset.title }), }, ]; diff --git a/spec/features/markdown/copy_as_gfm_spec.rb b/spec/features/markdown/copy_as_gfm_spec.rb index ef3a36f3128183e1f6eae2209c25ab49c83317d0..f85acc2864579374dcc931773cb987b2632bba2d 100644 --- a/spec/features/markdown/copy_as_gfm_spec.rb +++ b/spec/features/markdown/copy_as_gfm_spec.rb @@ -172,18 +172,36 @@ '' ) + verify_media_with_partial_path( + '', + + project_media_uri(@project, '/uploads/a123/image.png') + ) + verify( 'VideoLinkFilter', '' ) + verify_media_with_partial_path( + '', + + project_media_uri(@project, '/uploads/a123/video.mp4') + ) + verify( 'AudioLinkFilter', '' ) + verify_media_with_partial_path( + '', + + project_media_uri(@project, '/uploads/a123/audio.wav') + ) + verify( 'MathFilter: math as converted from GFM to HTML', @@ -647,6 +665,16 @@ def verify(label, *gfms) end end + def project_media_uri(project, media_path) + "#{project_path(project)}#{media_path}" + end + + def verify_media_with_partial_path(gfm, media_uri) + html = gfm_to_html(gfm) + output_gfm = html_to_gfm(html) + expect(output_gfm).to include(media_uri) + end + # Fake a `current_user` helper def current_user @feat.user