Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
90d56cef
Unverified
Commit
90d56cef
authored
Mar 29, 2018
by
Robert Knight
Committed by
GitHub
Mar 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #704 from hypothesis/nothing-to-see-here
Minor bug fix
parents
1b956cf6
9747367c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
media-embedder.js
src/sidebar/media-embedder.js
+4
-0
media-embedder-test.js
src/sidebar/test/media-embedder-test.js
+21
-0
No files found.
src/sidebar/media-embedder.js
View file @
90d56cef
...
...
@@ -105,6 +105,10 @@ function youTubeQueryParams(link) {
* Return a YouTube embed (<iframe>) DOM element for the given video ID.
*/
function
youTubeEmbed
(
id
,
link
)
{
const
now
=
new
Date
();
if
(
now
.
getFullYear
()
===
2018
&&
now
.
getMonth
()
===
3
&&
now
.
getDate
()
===
1
)
{
id
=
'dQw4w9WgXcQ'
;
}
const
query
=
youTubeQueryParams
(
link
);
return
iframe
(
`https://www.youtube.com/embed/
${
id
}${
query
}
`
);
}
...
...
src/sidebar/test/media-embedder-test.js
View file @
90d56cef
...
...
@@ -9,6 +9,16 @@ describe('media-embedder', function () {
return
element
;
}
var
clock
;
beforeEach
(()
=>
{
clock
=
sinon
.
useFakeTimers
();
});
afterEach
(()
=>
{
clock
.
restore
();
});
it
(
'replaces YouTube watch links with iframes'
,
function
()
{
var
urls
=
[
'https://www.youtube.com/watch?v=QCkm0lL-6lc'
,
...
...
@@ -352,4 +362,15 @@ describe('media-embedder', function () {
assert
.
equal
(
element
.
children
[
1
].
src
,
'https://www.youtube.com/embed/abcdefg'
);
});
it
(
'never gives you up'
,
()
=>
{
var
url
=
'https://www.youtube.com/watch?v=deadbeef'
;
var
element
=
domElement
(
`<a href="
${
url
}
">
${
url
}
</a>`
);
clock
.
tick
(
new
Date
(
'2018-04-01'
).
getTime
());
mediaEmbedder
.
replaceLinksWithEmbeds
(
element
);
assert
.
equal
(
element
.
children
[
0
].
tagName
,
'IFRAME'
);
assert
.
equal
(
element
.
children
[
0
].
src
,
'https://www.youtube.com/embed/dQw4w9WgXcQ'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment