Skip to content

Commit

Permalink
Merge pull request #1 from bolah2009/bb-fix-regex-for-capturing-categ…
Browse files Browse the repository at this point in the history
…ory-and-product-id

Fix regex for capturing category and product IDs
  • Loading branch information
meteor-ec authored Jun 13, 2024
2 parents b080326 + 06ed034 commit 2826cb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/ecwid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ export async function getCollections(): Promise<Collection[]> {
}

export async function getCollection(handle: string): Promise<Collection | undefined> {
let categoryId = handle.replace(/^.*?\-c/g, '');
let categoryId = handle.replace(/.*(?<=-c)/, '');

const res = await ecwidFetch<EcwidNode>({
method: 'GET',
Expand All @@ -751,7 +751,7 @@ export async function getCollectionProducts({
baseUrl: '/'
};

let categoryId = collection.replace(/^.*?\-c/g, '');
let categoryId = collection.replace(/.*(?<=-c)/, '');

if (collection != 'hidden-homepage-carousel' && collection != 'hidden-homepage-featured-items') {
query.categories = `${categoryId}`;
Expand Down Expand Up @@ -805,7 +805,7 @@ export async function getProducts({
}

export async function getProduct(handle: string): Promise<Product | undefined> {
let productId = handle.replace(/^.*?\-p/g, '');
let productId = handle.replace(/.*(?<=-p)/, '');

const res = await ecwidFetch<EcwidNode>({
method: 'GET',
Expand Down

0 comments on commit 2826cb5

Please sign in to comment.