Skip to content

Commit 9b64be4

Browse files
committed
initialize OpenGraph media slices before property handling
1 parent db071e6 commit 9b64be4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

extractors/opengraph.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ func parseOpenGraphMetaTag(og *OpenGraph, property, content string) {
333333
}
334334

335335
func handleOpenGraphImageProperty(og *OpenGraph, parts []string, content string) {
336+
if len(og.OpenGraphImage) == 0 {
337+
og.OpenGraphImage = []OpenGraphImage{}
338+
}
336339
if len(og.OpenGraphImage) == 0 || parts[1] == "image" {
337-
if len(parts) < 3 {
340+
if len(parts) < 3 || len(og.OpenGraphImage) == 0 {
338341
og.OpenGraphImage = append(og.OpenGraphImage, OpenGraphImage{})
339342
}
340343
}
@@ -360,8 +363,11 @@ func handleOpenGraphImageProperty(og *OpenGraph, parts []string, content string)
360363
}
361364

362365
func handleOpenGraphVideoProperty(og *OpenGraph, parts []string, content string) {
366+
if len(og.OpenGraphVideo) == 0 {
367+
og.OpenGraphVideo = []OpenGraphVideo{}
368+
}
363369
if len(og.OpenGraphVideo) == 0 || parts[1] == "video" {
364-
if len(parts) < 3 {
370+
if len(parts) < 3 || len(og.OpenGraphVideo) == 0 {
365371
og.OpenGraphVideo = append(og.OpenGraphVideo, OpenGraphVideo{})
366372
}
367373
}
@@ -385,8 +391,11 @@ func handleOpenGraphVideoProperty(og *OpenGraph, parts []string, content string)
385391
}
386392

387393
func handleOpenGraphAudioProperty(og *OpenGraph, parts []string, content string) {
394+
if len(og.OpenGraphAudio) == 0 {
395+
og.OpenGraphAudio = []OpenGraphAudio{}
396+
}
388397
if len(og.OpenGraphAudio) == 0 || parts[1] == "audio" {
389-
if len(parts) < 3 {
398+
if len(parts) < 3 || len(og.OpenGraphAudio) == 0 {
390399
og.OpenGraphAudio = append(og.OpenGraphAudio, OpenGraphAudio{})
391400
}
392401
}

0 commit comments

Comments
 (0)