Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors embedded youtube link regex #1155

Closed
wants to merge 1 commit into from
Closed

Refactors embedded youtube link regex #1155

wants to merge 1 commit into from

Conversation

ygrishajev
Copy link

So mobile link like 'http://m.youtube.com/...' can be embedded

@ygrishajev
Copy link
Author

ygrishajev commented Dec 2, 2016

Just some detailed explanation of the issue that is fixed by this pull request:

Youtube link differ for its mobile version: 'https://m.youtube.com/...'. So when such link is pasted into video embed tooltip an error is thrown:

Refused to display 'https://www.youtube.com/...' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

Steps for Reproduction

  1. Visit http://quilljs.com
  2. Try to embed youtube video (e.g. https://m.youtube.com/watch?v=IyTv_SR2uUo)
  3. See console errors

Expected behavior:

  1. Video is embedded properly
  2. No console errors

Actual behavior:
Error is thrown

Platforms:
IOS, OSX

Version:

1.1.5

So mobile link like 'http://m.youtube.com/...' can be embedded
@jhchen
Copy link
Member

jhchen commented Dec 2, 2016

Can you include tests? This regex is getting unwieldy with additional forms of YouTube links it is expected to support.

@benbro
Copy link
Contributor

benbro commented Dec 2, 2016

This is based on StackOverflow:

var reg = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([a-zA-Z0-9_-]+).*/;
var match = value.trim().match(reg);
if (match && match[2].length == 11) {
 value = 'https://www.youtube.com/embed/' + match[2] + '?showinfo=0';
}

@stalniy
Copy link

stalniy commented Dec 5, 2016

@jhchen Hi, could you please tell where you would like these tests to be in test/ folder? https://github.com/quilljs/quill/blob/develop/test/unit/blots/block-embed.js or a separate file for like test/unit/theme/base.js

@stalniy
Copy link

stalniy commented Dec 8, 2016

@jhchen could you please answer the question above? It's critical for me to have this and I can finish the pull request (i.e., add tests)

@jhchen
Copy link
Member

jhchen commented Dec 8, 2016

In terms of file organization it should probably go in theme/base.js since that is what is being tested. There may need to be some refactoring of the source code to enable unit testing which may influence which test/ folder or file it goes into.

@weavermedia
Copy link

weavermedia commented Dec 20, 2016

+1 😃 We're currently running into this issue. Is there anything blocking this merge?

@stalniy
Copy link

stalniy commented Dec 20, 2016

As a workaround you can create own theme which extends SnowTheme and monkey patch Tooltip. This is what I did

stalniy pushed a commit to stalniy/quill that referenced this pull request Jun 5, 2017
This allows to convert m.youtube.com and www.youtube.com to embedded url as well

Finishes work of slab#1155
@stalniy
Copy link

stalniy commented Jun 7, 2017

@ygrishajev you can close this. The work was finished in #1489

@ygrishajev ygrishajev closed this Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants