From a641cee54a029b9091cf2e05bf61983f06c5ee05 Mon Sep 17 00:00:00 2001
From: Marcos Passos <marcospassos@users.noreply.github.com>
Date: Mon, 28 Nov 2022 15:16:44 -0300
Subject: [PATCH] Refactor version extraction logic (#149)

---
 src/plug.ts | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/plug.ts b/src/plug.ts
index a61f492b..0129d36b 100644
--- a/src/plug.ts
+++ b/src/plug.ts
@@ -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> {