Skip to content

Commit

Permalink
fixed url encoding bug
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogTheFrog committed Jun 30, 2017
1 parent 8f91e2b commit d3af651
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/renderer/lib/image-providers/retrogaming.cloud.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { GenericImageProvider, ImageContent, ProviderEvent, AppSettings } from "../../models";
import { LoggerService, SettingsService } from "../../services";
import { Http, Headers, URLSearchParams, Response } from '@angular/http';
import { Http, Headers, URLSearchParams, Response, QueryEncoder } from '@angular/http';
import { Observable } from "rxjs";
import { queue } from 'async';
import { FuzzyMatcher } from "../fuzzy-matcher";

class CustomUrlEncoder extends QueryEncoder {
encodeKey(key: string): string {
return encodeURIComponent(key);
}

encodeValue(value: string): string {
return encodeURIComponent(value);
}
}

export class RetroGamingCloudProvider implements GenericImageProvider {
private timeoutQueue: AsyncQueue<{ timeout: number, eventCallback: () => void }>;
private timeoutTimer: any;
Expand Down Expand Up @@ -110,7 +120,7 @@ export class RetroGamingCloudProvider implements GenericImageProvider {
}

private retrieveImageList(title: string, eventCallback: (event: ProviderEvent, data: any) => void) {
let params = new URLSearchParams();
let params = new URLSearchParams('', new CustomUrlEncoder());
params.append('name', title);

return new Promise<any[]>((resolve, reject) => {
Expand Down
14 changes: 12 additions & 2 deletions src/renderer/lib/image-providers/steamgriddb.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import { GenericImageProvider, ImageContent, ProviderEvent } from "../../models";
import { LoggerService, SettingsService } from "../../services";
import { Http, Headers, URLSearchParams } from '@angular/http';
import { Http, Headers, URLSearchParams, QueryEncoder } from '@angular/http';
import { Observable } from "rxjs";

class CustomUrlEncoder extends QueryEncoder {
encodeKey(key: string): string {
return encodeURIComponent(key);
}

encodeValue(value: string): string {
return encodeURIComponent(value);
}
}

export class SteamGridDbProvider implements GenericImageProvider {
constructor(private http: Http, private loggerService: LoggerService, private settingsService: SettingsService, private downloadInterrupt: Observable<any>, private timeout: number = 40000, private retryCount: number = 3) { }

Expand All @@ -11,7 +21,7 @@ export class SteamGridDbProvider implements GenericImageProvider {
}

retrieveUrls(title: string, eventCallback: (event: ProviderEvent, data: any) => void, doneCallback: (title: string) => void) {
let params = new URLSearchParams();
let params = new URLSearchParams('', new CustomUrlEncoder());
params.append('game', title);
params.append('fields', ['author', 'grid_url'].toString());

Expand Down

0 comments on commit d3af651

Please sign in to comment.