Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vmap/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (adBreak *AdBreak) UnmarshalToken(tok *xmltokenizer.Tokenizer, se *xmltoken
switch string(token.Name.Local) {
case "VAST":
var vast VAST
if token.SelfClosing {
break
}
// Reuse Token object in the sync.Pool since we only use it temporarily.
se := xmltokenizer.GetToken().Copy(token)
err = vast.UnmarshalToken(tok, se)
Expand Down
14 changes: 14 additions & 0 deletions vmap/sample-vmap/testVmapEmptyVast.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vmap:VMAP version="1.0" xmlns:vmap="http://www.iab.net/vmap-1.0">
<vmap:AdBreak breakId="midroll.ad-1" breakType="linear" timeOffset="start">
<vmap:AdSource id="1" allowMultipleAds="true" followRedirects="true">
<vmap:VASTAdData>
<VAST version="4.1" />
</vmap:VASTAdData>
</vmap:AdSource>
<vmap:TrackingEvents>
<vmap:Tracking event="breakStart"><![CDATA[
http://test-adserver.domain/api/v1/sessions/331cea0b-f9a0-4ad3-b07c-e552f003316d/tracking?adId=midroll.ad-3&progress=vmap
]]></vmap:Tracking>
</vmap:TrackingEvents>
</vmap:AdBreak>
</vmap:VMAP>
11 changes: 11 additions & 0 deletions vmap/structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ func TestDecodeEmptyVmap(t *testing.T) {
is.Equal(len(vmap.AdBreaks), 0)
}

func TestDecodeVmapEmptyVast(t *testing.T) {
is := is.New(t)
doc, err := os.ReadFile("sample-vmap/testVmapEmptyVast.xml")
is.NoErr(err)

vmap, err := DecodeVmap(doc)
is.NoErr(err)

is.Equal(len(vmap.AdBreaks), 1)
}

func TestDecodeEmptyVast(t *testing.T) {
is := is.New(t)
doc, err := os.ReadFile("sample-vmap/testVast3.xml")
Expand Down
Loading