From 5949417efefc79f948d096fdf7c12ff8cd8e9e16 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 3 Jun 2024 13:48:58 +0200 Subject: [PATCH 01/11] Implemented filtering cards by partner level --- eds/components/PartnerCards.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index a00a194..6e2e8b6 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -185,8 +185,11 @@ export class PartnerCards extends LitElement { const { collectionTags, language, country } = this.blockData; - if (collectionTags) { - api.searchParams.set('collectionTags', collectionTags); + const partnerDataCollectionTag = this.getPartnerDataCollectionTag(); + const mergedCollectionTags = collectionTags ? `${collectionTags}&${partnerDataCollectionTag}` : partnerDataCollectionTag; + + if (mergedCollectionTags) { + api.searchParams.set('collectionTags', mergedCollectionTags); } if (language && country) { @@ -209,6 +212,25 @@ export class PartnerCards extends LitElement { } } + getPartnerDataCollectionTag () { + let cookies = document.cookie.split(';').map(cookie => cookie.trim()); + let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); + if(!partnerDataCookie) return ''; + const { level } = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); + const portal = this.blockData.ietf === 'en-US' ? this.getProgramType(window.location.pathname.split('/')[1]) : this.getProgramType(window.location.pathname.split('/')[2]); + if(!portal) return ''; + return `caas:adobe-partners/${portal}/partner-level/${level}` + } + + getProgramType(path) { + switch(path) { + case 'solutionpartners': return 'spp'; + case 'technologypartners': return 'tpp'; + case 'channelpartners': return 'cpp'; + default: return ''; + } + } + initUrlSearchParams () { const { search } = location || window.location; this.urlSearchParams = new URLSearchParams(search); From 5b88ff0e25c66393f080833e0ad8adbb75598e4b Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 3 Jun 2024 14:37:41 +0200 Subject: [PATCH 02/11] Minor changes --- eds/components/PartnerCards.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 6e2e8b6..7820cf8 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -213,20 +213,25 @@ export class PartnerCards extends LitElement { } getPartnerDataCollectionTag () { - let cookies = document.cookie.split(';').map(cookie => cookie.trim()); - let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); - if(!partnerDataCookie) return ''; - const { level } = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); - const portal = this.blockData.ietf === 'en-US' ? this.getProgramType(window.location.pathname.split('/')[1]) : this.getProgramType(window.location.pathname.split('/')[2]); - if(!portal) return ''; - return `caas:adobe-partners/${portal}/partner-level/${level}` + try { + let cookies = document.cookie.split(';').map(cookie => cookie.trim()); + let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); + if (!partnerDataCookie) return ''; + const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); + const portal = this.getProgramType(window.location.pathname); + if (!portal || !level) return ''; + return `caas:adobe-partners/${portal}/partner-level/${level}` + } catch(error) { + console.error('Error parsing partner data object:', error); + return ''; + } } getProgramType(path) { - switch(path) { - case 'solutionpartners': return 'spp'; - case 'technologypartners': return 'tpp'; - case 'channelpartners': return 'cpp'; + switch(true) { + case /solutionpartners/.test(path): return 'spp'; + case /technologypartners/.test(path): return 'tpp'; + case /channelpartners/.test(path): return 'cpp'; default: return ''; } } From 7836031d7193bea3f4507f613329f13f6db653a1 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Tue, 4 Jun 2024 12:29:51 +0200 Subject: [PATCH 03/11] Minor change --- eds/components/PartnerCards.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 7820cf8..9f49c35 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -186,7 +186,9 @@ export class PartnerCards extends LitElement { const { collectionTags, language, country } = this.blockData; const partnerDataCollectionTag = this.getPartnerDataCollectionTag(); - const mergedCollectionTags = collectionTags ? `${collectionTags}&${partnerDataCollectionTag}` : partnerDataCollectionTag; + const mergedCollectionTags = collectionTags ? `${collectionTags},${partnerDataCollectionTag}` : partnerDataCollectionTag; + console.log("Caoo", mergedCollectionTags); + if (mergedCollectionTags) { api.searchParams.set('collectionTags', mergedCollectionTags); From dc59e97ebf1a0b4f81c1ad013879e471eee15c9e Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Tue, 4 Jun 2024 12:30:18 +0200 Subject: [PATCH 04/11] Deleted console.log --- eds/components/PartnerCards.js | 1 - 1 file changed, 1 deletion(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 9f49c35..1cf2f30 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -187,7 +187,6 @@ export class PartnerCards extends LitElement { const partnerDataCollectionTag = this.getPartnerDataCollectionTag(); const mergedCollectionTags = collectionTags ? `${collectionTags},${partnerDataCollectionTag}` : partnerDataCollectionTag; - console.log("Caoo", mergedCollectionTags); if (mergedCollectionTags) { From 19d3fecf0538f554a9fc34a6f21fd70035186450 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 10 Jun 2024 12:05:37 +0200 Subject: [PATCH 05/11] added complexQuery param and logic --- eds/components/PartnerCards.js | 53 +++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 1cf2f30..a6040cc 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -185,12 +185,21 @@ export class PartnerCards extends LitElement { const { collectionTags, language, country } = this.blockData; - const partnerDataCollectionTag = this.getPartnerDataCollectionTag(); - const mergedCollectionTags = collectionTags ? `${collectionTags},${partnerDataCollectionTag}` : partnerDataCollectionTag; - + // const partnerDataCollectionTag = this.getPartnerDataCollectionTag(); + // const mergedCollectionTags = collectionTags ? `${collectionTags},${partnerDataCollectionTag}` : partnerDataCollectionTag; + // + // + // if (mergedCollectionTags) { + // api.searchParams.set('collectionTags', mergedCollectionTags); + // } + + if(collectionTags) { + api.searchParams.set('collectionTags', collectionTags); + } - if (mergedCollectionTags) { - api.searchParams.set('collectionTags', mergedCollectionTags); + const partnerDataComplexQueryParam = this.getPartnerDataComplexQueryParam(); + if(partnerDataComplexQueryParam) { + api.searchParams.set('complexQuery', partnerDataComplexQueryParam); } if (language && country) { @@ -213,21 +222,45 @@ export class PartnerCards extends LitElement { } } - getPartnerDataCollectionTag () { + getPartnerDataComplexQueryParam () { try { + const portal = this.getProgramType(window.location.pathname); let cookies = document.cookie.split(';').map(cookie => cookie.trim()); let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); - if (!partnerDataCookie) return ''; + + if (!partnerDataCookie) return `(("caas:adobe-partners/${portal}/partner-level/public")OR(""))`; const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); - const portal = this.getProgramType(window.location.pathname); - if (!portal || !level) return ''; - return `caas:adobe-partners/${portal}/partner-level/${level}` + if(!portal) + return ''; + + if (!level) + return `(("caas:adobe-partners/${portal}/partner-level/public")OR(""))`; + + return `(("caas:adobe-partners/${portal}/partner-level/${level}")OR("caas:adobe-partners/${portal}/partner-level/public"))`; } catch(error) { console.error('Error parsing partner data object:', error); return ''; } } + // getPartnerDataCollectionTag () { + // try { + // let cookies = document.cookie.split(';').map(cookie => cookie.trim()); + // let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); + // if (!partnerDataCookie) return ''; + // const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); + // const portal = this.getProgramType(window.location.pathname); + // if (!portal || !level) return ''; + // else if(portal && level) + // return `` + // else + // return `caas:adobe-partners/${portal}/partner-level/${level}` + // } catch(error) { + // console.error('Error parsing partner data object:', error); + // return ''; + // } + // } + getProgramType(path) { switch(true) { case /solutionpartners/.test(path): return 'spp'; From 86b0c9d766a82333c071ee7c422f61265cf96ef0 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 10 Jun 2024 13:54:44 +0200 Subject: [PATCH 06/11] removed unnecessary code --- eds/components/PartnerCards.js | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index a6040cc..1e763a5 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -185,14 +185,6 @@ export class PartnerCards extends LitElement { const { collectionTags, language, country } = this.blockData; - // const partnerDataCollectionTag = this.getPartnerDataCollectionTag(); - // const mergedCollectionTags = collectionTags ? `${collectionTags},${partnerDataCollectionTag}` : partnerDataCollectionTag; - // - // - // if (mergedCollectionTags) { - // api.searchParams.set('collectionTags', mergedCollectionTags); - // } - if(collectionTags) { api.searchParams.set('collectionTags', collectionTags); } @@ -243,24 +235,6 @@ export class PartnerCards extends LitElement { } } - // getPartnerDataCollectionTag () { - // try { - // let cookies = document.cookie.split(';').map(cookie => cookie.trim()); - // let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); - // if (!partnerDataCookie) return ''; - // const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); - // const portal = this.getProgramType(window.location.pathname); - // if (!portal || !level) return ''; - // else if(portal && level) - // return `` - // else - // return `caas:adobe-partners/${portal}/partner-level/${level}` - // } catch(error) { - // console.error('Error parsing partner data object:', error); - // return ''; - // } - // } - getProgramType(path) { switch(true) { case /solutionpartners/.test(path): return 'spp'; From 0db833be784e2cfdc7b84ff0d1f6b5bf5196c01b Mon Sep 17 00:00:00 2001 From: Dragana Trajkovic Date: Wed, 12 Jun 2024 17:06:20 +0200 Subject: [PATCH 07/11] Refactored code; no results is displayed if there are no fetched cards; added portal and component specific collectionTags --- .../knowledge-base-overview.js | 3 +- eds/blocks/partner-news/partner-news.js | 3 +- eds/components/PartnerCards.js | 79 +++++++++++-------- 3 files changed, 49 insertions(+), 36 deletions(-) diff --git a/eds/blocks/knowledge-base-overview/knowledge-base-overview.js b/eds/blocks/knowledge-base-overview/knowledge-base-overview.js index 6a30ee3..0f96cd8 100644 --- a/eds/blocks/knowledge-base-overview/knowledge-base-overview.js +++ b/eds/blocks/knowledge-base-overview/knowledge-base-overview.js @@ -55,7 +55,8 @@ export default async function init(el) { 'localizedText': localizedText, 'tableData' : el.children, 'cardsPerPage': 9, - 'ietf': config.locale.ietf + 'ietf': config.locale.ietf, + 'collectionTags': 'caas:adobe-partners/collections/knowledge-base' } const app = document.createElement('knowledge-base-overview'); diff --git a/eds/blocks/partner-news/partner-news.js b/eds/blocks/partner-news/partner-news.js index 0593e54..de63bbd 100644 --- a/eds/blocks/partner-news/partner-news.js +++ b/eds/blocks/partner-news/partner-news.js @@ -68,7 +68,8 @@ export default async function init(el) { 'tableData' : el.children, 'dateFilter': dateFilter, 'cardsPerPage': 12, - 'ietf': config.locale.ietf + 'ietf': config.locale.ietf, + 'collectionTags': 'caas:adobe-partners/collections/news' } const app = document.createElement('partner-news'); diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 32e1efa..6fef7dd 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -89,6 +89,8 @@ export class PartnerCards extends LitElement { this.selectedSortOrder = {}; this.selectedFilters = {}; this.urlSearchParams = {}; + this.collectionTags = []; + this.hasResponseData = false; this.mobileView = window.innerWidth <= 1200; this.updateView = this.updateView.bind(this); } @@ -108,11 +110,12 @@ export class PartnerCards extends LitElement { 'default': {}, items: [] }, - 'collectionTags': '', 'language': '', 'country': '' }; + this.collectionTags = [ this.blockData.collectionTags ]; + const blockDataActions = { 'title': (cols) => { const [titleEl] = cols; @@ -162,8 +165,7 @@ export class PartnerCards extends LitElement { 'collection-tags': (cols) => { const [collectionTagsEl] = cols; const collectionTags = Array.from(collectionTagsEl.querySelectorAll('li'), (li) => li.innerText.trim().toLowerCase()); - const collectionTagsParamStr = collectionTags.filter(e => e.length).join(','); - this.blockData.collectionTags = collectionTagsParamStr; + this.collectionTags = [...this.collectionTags, ...collectionTags]; } } @@ -173,7 +175,7 @@ export class PartnerCards extends LitElement { const rowTitle = cols[0].innerText.trim().toLowerCase().replaceAll(' ', '-'); const colsContent = cols.slice(1); if (blockDataActions[rowTitle]) blockDataActions[rowTitle](colsContent); - }) + }); const ietfArr = this.blockData.ietf.split('-'); this.blockData.language = ietfArr[0]; @@ -196,24 +198,8 @@ export class PartnerCards extends LitElement { async fetchData() { try { const api = new URL('https://14257-chimera.adobeioruntime.net/api/v1/web/chimera-0.0.1/collection?originSelection=dx-partners&draft=false&debug=true&flatFile=false&expanded=true'); - - const { collectionTags, language, country } = this.blockData; - - if(collectionTags) { - api.searchParams.set('collectionTags', collectionTags); - } - - const partnerDataComplexQueryParam = this.getPartnerDataComplexQueryParam(); - if(partnerDataComplexQueryParam) { - api.searchParams.set('complexQuery', partnerDataComplexQueryParam); - } - - if (language && country) { - api.searchParams.set('language', language); - api.searchParams.set('country', country); - } - - const response = await fetch(api.toString()); + const apiWithParams = this.setApiParams(api); + const response = await fetch(apiWithParams); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } @@ -227,27 +213,52 @@ export class PartnerCards extends LitElement { apiData.cards.forEach((card, index) => card.orderNum = index + 1); this.allCards = this.cards = apiData.cards; this.paginatedCards = this.cards.slice(0, this.cardsPerPage); + this.hasResponseData = true; + } else { + this.hasResponseData = false; } } catch (error) { console.error('Error fetching data:', error); } } - getPartnerDataComplexQueryParam () { + setApiParams(api) { + const portal = this.getProgramType(window.location.pathname); + + if (portal) { + const portalCollectionTag = `caas:adobe-partners/${portal}`; + if (!this.collectionTags.length || !this.collectionTags.includes(portalCollectionTag)) { + this.collectionTags = [...this.collectionTags, portalCollectionTag]; + } + + const partnerDataComplexQueryParam = this.getPartnerDataComplexQueryParam(portal); + if (partnerDataComplexQueryParam) api.searchParams.set('complexQuery', partnerDataComplexQueryParam); + } + + if(this.collectionTags.length) { + const collectionTagsStr = this.collectionTags.filter(e => e.length).join(','); + api.searchParams.set('collectionTags', collectionTagsStr); + } + + const { language, country } = this.blockData; + if (language && country) { + api.searchParams.set('language', language); + api.searchParams.set('country', country); + } + + return api.toString(); + } + + getPartnerDataComplexQueryParam (portal) { try { - const portal = this.getProgramType(window.location.pathname); - let cookies = document.cookie.split(';').map(cookie => cookie.trim()); - let partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); + const cookies = document.cookie.split(';').map(cookie => cookie.trim()); + const partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); + if (!partnerDataCookie) return `(("caas:adobe-partners/${portal}/partner-level/public"))`; - if (!partnerDataCookie) return `(("caas:adobe-partners/${portal}/partner-level/public")OR(""))`; const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); - if(!portal) - return ''; - - if (!level) - return `(("caas:adobe-partners/${portal}/partner-level/public")OR(""))`; + if (!level) return `(("caas:adobe-partners/${portal}/partner-level/public"))`; - return `(("caas:adobe-partners/${portal}/partner-level/${level}")OR("caas:adobe-partners/${portal}/partner-level/public"))`; + return `(("caas:adobe-partners/${portal}/partner-level/${level}")+OR+("caas:adobe-partners/${portal}/partner-level/public"))`; } catch(error) { console.error('Error parsing partner data object:', error); return ''; @@ -721,7 +732,7 @@ export class PartnerCards extends LitElement {
- ${this.allCards.length + ${this.hasResponseData ? this.partnerCards : html`
From 7158aae17a0e4326f402648b5017302a437041c4 Mon Sep 17 00:00:00 2001 From: Dragana Trajkovic Date: Wed, 12 Jun 2024 18:22:35 +0200 Subject: [PATCH 08/11] removed unnecessary line --- eds/components/PartnerCards.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 6fef7dd..e1a1554 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -214,8 +214,6 @@ export class PartnerCards extends LitElement { this.allCards = this.cards = apiData.cards; this.paginatedCards = this.cards.slice(0, this.cardsPerPage); this.hasResponseData = true; - } else { - this.hasResponseData = false; } } catch (error) { console.error('Error fetching data:', error); From 215d8895cceac33b2c59fd1b4c06a57eb6838ed8 Mon Sep 17 00:00:00 2001 From: Dragana Trajkovic Date: Thu, 13 Jun 2024 14:39:11 +0200 Subject: [PATCH 09/11] updated unit test --- .../knowledge-base-overview/knowledge-base-overview.test.js | 1 + test/blocks/partner-news/partner-news.test.js | 1 + 2 files changed, 2 insertions(+) diff --git a/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js b/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js index 97f2793..6966dc8 100644 --- a/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js +++ b/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js @@ -14,6 +14,7 @@ describe('knowledge-base-overview block', () => { sinon.stub(PartnerCards.prototype, 'firstUpdated').callsFake(async function() { this.allCards = this.cards = cards; this.paginatedCards = this.cards.slice(0, 3); + this.hasResponseData = true; }); await import('./../../../eds/scripts/scripts.js'); diff --git a/test/blocks/partner-news/partner-news.test.js b/test/blocks/partner-news/partner-news.test.js index 069cb85..d3cc710 100644 --- a/test/blocks/partner-news/partner-news.test.js +++ b/test/blocks/partner-news/partner-news.test.js @@ -14,6 +14,7 @@ describe('partner-news block', () => { sinon.stub(PartnerCards.prototype, 'firstUpdated').callsFake(async function() { this.allCards = this.cards = cards; this.paginatedCards = this.cards.slice(0, 3); + this.hasResponseData = true; }); await import('./../../../eds/scripts/scripts.js'); From 62dcbe1f3a90cce5dd0c3819ff49418b91a8de0a Mon Sep 17 00:00:00 2001 From: Dragana Trajkovic Date: Fri, 14 Jun 2024 12:24:23 +0200 Subject: [PATCH 10/11] updated complexQuery with changed cookie --- eds/components/PartnerCards.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index e1a1554..c59639a 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -249,14 +249,17 @@ export class PartnerCards extends LitElement { getPartnerDataComplexQueryParam (portal) { try { + const publicTag = `(("caas:adobe-partners/${portal}/partner-level/public"))`; const cookies = document.cookie.split(';').map(cookie => cookie.trim()); const partnerDataCookie = cookies.find(cookie => cookie.startsWith('partner_data=')); - if (!partnerDataCookie) return `(("caas:adobe-partners/${portal}/partner-level/public"))`; + if (!partnerDataCookie) return publicTag; - const {level} = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); - if (!level) return `(("caas:adobe-partners/${portal}/partner-level/public"))`; - - return `(("caas:adobe-partners/${portal}/partner-level/${level}")+OR+("caas:adobe-partners/${portal}/partner-level/public"))`; + const cookieValue = JSON.parse(partnerDataCookie.substring(('partner_data=').length).toLowerCase()); + if (cookieValue && cookieValue[portal]) { + const cookieLevel = cookieValue[portal].level; + if (cookieLevel) return `(("caas:adobe-partners/${portal}/partner-level/${cookieLevel}")+OR+("caas:adobe-partners/${portal}/partner-level/public"))`; + } + return publicTag; } catch(error) { console.error('Error parsing partner data object:', error); return ''; @@ -267,7 +270,7 @@ export class PartnerCards extends LitElement { switch(true) { case /solutionpartners/.test(path): return 'spp'; case /technologypartners/.test(path): return 'tpp'; - case /channelpartners/.test(path): return 'cpp'; + case /channelpartners/.test(path): return 'apc'; default: return ''; } } From dc6f680434ef5f549cbfc8bfd2e2dc06a8d4e72e Mon Sep 17 00:00:00 2001 From: Dragana Trajkovic Date: Fri, 14 Jun 2024 13:09:23 +0200 Subject: [PATCH 11/11] program type for cpp fix --- eds/components/PartnerCards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index c59639a..abba8e5 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -270,7 +270,7 @@ export class PartnerCards extends LitElement { switch(true) { case /solutionpartners/.test(path): return 'spp'; case /technologypartners/.test(path): return 'tpp'; - case /channelpartners/.test(path): return 'apc'; + case /channelpartners/.test(path): return 'cpp'; default: return ''; } }