diff --git a/endpoints/openrtb2/amp_auction.go b/endpoints/openrtb2/amp_auction.go index 586481ddfc5..2dcd572c63c 100644 --- a/endpoints/openrtb2/amp_auction.go +++ b/endpoints/openrtb2/amp_auction.go @@ -407,31 +407,34 @@ func (deps *endpointDeps) overrideWithParams(httpRequest *http.Request, req *ope } func makeFormatReplacement(overrideWidth uint64, overrideHeight uint64, width uint64, height uint64, multisize string) []openrtb.Format { + var formats []openrtb.Format if overrideWidth != 0 && overrideHeight != 0 { - return []openrtb.Format{{ + formats = []openrtb.Format{{ W: overrideWidth, H: overrideHeight, }} } else if overrideWidth != 0 && height != 0 { - return []openrtb.Format{{ + formats = []openrtb.Format{{ W: overrideWidth, H: height, }} } else if width != 0 && overrideHeight != 0 { - return []openrtb.Format{{ + formats = []openrtb.Format{{ W: width, H: overrideHeight, }} - } else if parsedSizes := parseMultisize(multisize); len(parsedSizes) != 0 { - return parsedSizes } else if width != 0 && height != 0 { - return []openrtb.Format{{ + formats = []openrtb.Format{{ W: width, H: height, }} } - return nil + if parsedSizes := parseMultisize(multisize); len(parsedSizes) != 0 { + formats = append(formats, parsedSizes...) + } + + return formats } func setWidths(formats []openrtb.Format, width uint64) { diff --git a/endpoints/openrtb2/amp_auction_test.go b/endpoints/openrtb2/amp_auction_test.go index 289db3f48cb..731fd55e196 100644 --- a/endpoints/openrtb2/amp_auction_test.go +++ b/endpoints/openrtb2/amp_auction_test.go @@ -832,6 +832,24 @@ func TestMultisize(t *testing.T) { }.execute(t) } +func TestSizeWithMultisize(t *testing.T) { + formatOverrideSpec{ + width: 20, + height: 40, + multisize: "200x50,100x60", + expect: []openrtb.Format{{ + W: 20, + H: 40, + }, { + W: 200, + H: 50, + }, { + W: 100, + H: 60, + }}, + }.execute(t) +} + func TestHeightOnly(t *testing.T) { formatOverrideSpec{ height: 200,