Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

[amp] site.pageパラメータをampページURLに変更する機能追加 #12

Merged
merged 1 commit into from
Jul 29, 2021
Merged
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
14 changes: 14 additions & 0 deletions endpoints/openrtb2/amp_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ func (deps *endpointDeps) AmpAuction(w http.ResponseWriter, r *http.Request, _ h
LegacyLabels: labels,
}

u, errUrl := url.Parse(r.Header.Get("Referer"))

auctionRequest.BidRequest.Site.Domain = auctionRequest.BidRequest.Site.Page

if errUrl == nil {
if u.Host == auctionRequest.BidRequest.Site.Page {
auctionRequest.BidRequest.Site.Domain = auctionRequest.BidRequest.Site.Page
auctionRequest.BidRequest.Site.Page = u.Host + u.Path
} else if dirs := strings.Split(u.Path, "/"); len(dirs) >= 4 && dirs[3] == auctionRequest.BidRequest.Site.Page {
auctionRequest.BidRequest.Site.Domain = dirs[3]
auctionRequest.BidRequest.Site.Page = strings.Join(dirs[3:], "/")
}
}

response, err := deps.ex.HoldAuction(ctx, auctionRequest, nil)
ao.AuctionResponse = response

Expand Down