Question

I'm working on a plugin that converts soundcloud URLs to embeds in the WYSIWYG editor Redactor. Currently its working well with one exception. If the first thing you do in the editor is paste a soundcloud URL and press enter, it will result in an error of:

url parameter is not a valid SoundCloud URL. Learn more about using SoundCloud embeds.

If you then paste the same soundcloud URL and press enter, the embed will work fine. Upon inspecting the HTML, the urls look identical, so I'm not sure what is causing this issue. It will also work if you load the page, press enter, paste in soundcloud url, and then press enter.

I'm not sure if this is a Redactor issue or a Soundcloud issue or if I've done something incorrect. Any advice is much appreciated. Thanks!

My current demo: http://caseybritt.com/_tmp/redactor-sc/

Was it helpful?

Solution

Redactor uses zero width spaces that you'll need to strip off your matches before constructing the URL for SoundCloud embed.

matches[2].replace(/u200B/g, '')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top