Skip to content

Commit

Permalink
Merge pull request #109 from deriv-com/mayuran/sitemap
Browse files Browse the repository at this point in the history
fix: new changes sitemap
  • Loading branch information
ali-hosseini-deriv authored Aug 16, 2024
2 parents c89ed6d + 90b5885 commit 553582d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions .github/modify_sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,25 @@ const argv = yargs
// Get the new domain and input file from command-line arguments
const newDomain = argv["new-domain"];
const inputFile = argv["input-file"];
// Define the new domain
// Read the input file
fs.readFile(inputFile, "utf8", (err, data) => {
if (err) {
console.error("Error reading the file:", err);
return;
}

// Define the pattern to match the URLs
const pattern = /https:\/\/([^.]*\.)?deriv\.(com|be|me)/g;

// Replace the matched URLs with the new domain
const newContent = data.replace(pattern, `https://${newDomain}`);

// Write the modified content to the output file
fs.writeFile(inputFile, newContent, "utf8", (err) => {
const urlBlockPattern = /(<url>[\s\S]*?<\/url>)/g;

let filteredContent = newContent.replace(urlBlockPattern, (match) => {
if (/https:\/\/deriv\.com\/eu\//.test(match)) {
return "";
}
return match;
});

fs.writeFile(inputFile, filteredContent, "utf8", (err) => {
if (err) {
console.error("Error writing the file:", err);
return;
Expand Down

0 comments on commit 553582d

Please sign in to comment.