Skip to content

Commit

Permalink
Refactor version extraction logic (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos authored Nov 28, 2022
1 parent 674f23f commit a641cee
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/plug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,12 @@ export class GlobalPlug implements Plug {
slotId: I,
options: FetchOptions = {},
): Promise<LegacyFetchResponse<I, C>> => {
const [id, version] = slotId.split('@') as [string, `${number}` | 'latest' | undefined];
const [id, version = 'latest'] = slotId.split('@') as [string, `${number}` | 'latest' | undefined];
const logger = this.sdk.getLogger();

return this.sdk
.contentFetcher
.fetch<SlotContent<I, C>>(id, {
...options,
version: version === 'latest' ? undefined : version,
})
.fetch<SlotContent<I, C>>(id, version === 'latest' ? options : {...options, version: version})
.then(
response => ({
get payload(): SlotContent<I, C> {
Expand Down

0 comments on commit a641cee

Please sign in to comment.