mirror of
https://github.com/nkanaev/yarr.git
synced 2025-11-09 02:49:37 +00:00
gofmt -s -w .
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
var (
|
||||
youtubeFrame = `<iframe src="https://www.youtube.com/embed/%s" width="560" height="315" frameborder="0" allowfullscreen></iframe>`
|
||||
vimeoFrame = `<iframe src="https://player.vimeo.com/video/%s" width="640" height="360" frameborder="0" allowfullscreen></iframe>`
|
||||
vimeoRegex = regexp.MustCompile(`\/(\d+)$`)
|
||||
vimeoFrame = `<iframe src="https://player.vimeo.com/video/%s" width="640" height="360" frameborder="0" allowfullscreen></iframe>`
|
||||
vimeoRegex = regexp.MustCompile(`\/(\d+)$`)
|
||||
)
|
||||
|
||||
func VideoIFrame(link string) string {
|
||||
@@ -31,7 +31,7 @@ func VideoIFrame(link string) string {
|
||||
|
||||
if l.Host == "vimeo.com" {
|
||||
if matches := vimeoRegex.FindStringSubmatch(l.Path); len(matches) > 0 {
|
||||
return fmt.Sprintf(vimeoFrame, matches[1])
|
||||
return fmt.Sprintf(vimeoFrame, matches[1])
|
||||
}
|
||||
}
|
||||
return ""
|
||||
|
||||
@@ -9,7 +9,7 @@ func TestYoutubeIframe(t *testing.T) {
|
||||
"https://youtu.be/dQw4w9WgXcQ",
|
||||
}
|
||||
for _, link := range links {
|
||||
have := VideoIFrame(link)
|
||||
have := VideoIFrame(link)
|
||||
want := `<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" width="560" height="315" frameborder="0" allowfullscreen></iframe>`
|
||||
if have != want {
|
||||
t.Logf("want: %s", want)
|
||||
@@ -25,7 +25,7 @@ func TestVimeoIframe(t *testing.T) {
|
||||
"https://vimeo.com/526381128",
|
||||
}
|
||||
for _, link := range links {
|
||||
have := VideoIFrame(link)
|
||||
have := VideoIFrame(link)
|
||||
want := `<iframe src="https://player.vimeo.com/video/526381128" width="640" height="360" frameborder="0" allowfullscreen></iframe>`
|
||||
if have != want {
|
||||
t.Logf("want: %s", want)
|
||||
|
||||
Reference in New Issue
Block a user