Skip to content

Commit

Permalink
data: fix box_art_url bug in TwitchSearchGame
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Jan 24, 2022
1 parent e45a695 commit f55aafa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/data/models/twitch/search-game/serializer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import TwitchSerializer from "data/models/twitch/serializer";


const reStaticBoxArtRes = /\d+x\d+\.(\w+)$/;


export default TwitchSerializer.extend({
modelNameFromPayloadKey() {
return "twitch-search-game";
Expand All @@ -12,6 +15,14 @@ export default TwitchSerializer.extend({

normalize( modelClass, resourceHash, prop ) {
const { primaryKey } = this;

// workaround for: https://github.com/twitchdev/issues/issues/329
/* istanbul ignore next */
if ( resourceHash[ "box_art_url" ] ) {
resourceHash[ "box_art_url" ] = `${resourceHash[ "box_art_url" ]}`
.replace( reStaticBoxArtRes, "{width}x{height}.$1" );
}

resourceHash = {
[ primaryKey ]: resourceHash[ primaryKey ],
game: resourceHash
Expand Down

0 comments on commit f55aafa

Please sign in to comment.