Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Remove destructuring from generateRequestUrl signature #363

Merged
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
7 changes: 3 additions & 4 deletions src/request/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import { forOf } from '@dojo/shim/iterator';
* @param url The base URL.
* @param options The RequestOptions used to generate the query string or cacheBust.
*/
export function generateRequestUrl(url: string,
{ query, cacheBust }: RequestOptions = {}): string {
query = new UrlSearchParams(query).toString();
if (cacheBust) {
export function generateRequestUrl(url: string, options: RequestOptions = {}): string {
let query = new UrlSearchParams(options.query).toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just move the destructering down?

export function generateRequestUrl(url: string, options: RequestOptions = {}): string {
    let { query, cacheBust } = options;

Copy link
Member Author

@nicknisi nicknisi Nov 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it for a couple reasons:

  • I thought it'd be weird to set query and then set it again on the line after it.
	let { query, cacheBust } = options;
	query = new UrlSearchParams(query).toString();
  • I didn't want cacheBust to be a let variable since it's not modified.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, ok, and it is only accessed once (cacheBust) 👍

if (options.cacheBust) {
const bustString = String(Date.now());
query += query ? `&${bustString}` : bustString;
}
Expand Down