Skip to content

Commit

Permalink
Removing graybox domain suffic from the links
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekhar Sirivuri committed Apr 18, 2024
1 parent 002423f commit 09efdeb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions actions/docxUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const { fetchWithRetry } = require('./sharepoint');
const gbStyleExpression = 'gb-';//graybox style expression. need to revisit if there are any more styles to be considered.
const emptyString = '';
const grayboxStylesRegex = new RegExp('gb-[a-zA-Z0-9,._-]*', 'g');
const gbDomainSuffix = '-graybox';
const logger = getAioLogger();
let firstGtRows = [];

Expand All @@ -37,7 +38,7 @@ async function updateDocument(mdPath, expName, options = {}){
firstGtRows = [];
const response = await fetchWithRetry(`${mdPath}`, options);
const content = await response.text();
if (content.includes(expName) || content.includes(gbStyleExpression)) {
if (content.includes(expName) || content.includes(gbStyleExpression) || content.includes(gbDomainSuffix)) {
const state = { content: { data: content }, log: '' };
await parseMarkdown(state);
const { mdast } = state.content;
Expand Down Expand Up @@ -65,8 +66,8 @@ const updateExperienceNameFromLinks = (mdast, expName) => {
firstGtRows.push(findFirstGtRowInNode(child));
}
//remove experience name from links on the document
if (child.type === 'link' && child.url && child.url.includes(expName)) {
child.url = child.url.replaceAll(expName, emptyString);
if (child.type === 'link' && child.url && (child.url.includes(expName) || child.url.includes(gbDomainSuffix))) {
child.url = child.url.replaceAll(expName, emptyString).replaceAll(gbDomainSuffix, emptyString);
}
if (child.children) {
updateExperienceNameFromLinks(child.children, expName);
Expand Down

0 comments on commit 09efdeb

Please sign in to comment.