-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.js
38 lines (38 loc) · 1.26 KB
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getContext = (text) => {
console.log("getContext");
console.log("'" + text + "'");
const foundText = text.match(
/<!--- LOKALIZE CONTEXT FOR TRANSLATORS -->((.|\n|\r|\t|\0)*)<!--- LOKALIZE CONTEXT FOR TRANSLATORS -->/
);
console.log(foundText);
console.log(foundText[1]);
return foundText ? foundText[1] : "";
};
const getClubhouseLink = (text) => {
const clubhouseLink = text.match(/Clubhouse Story: (.*)/);
return clubhouseLink ? clubhouseLink[0] : "";
};
const getAllImages = (text) => {
const listOfImages = text.match(
/(http|ftp|https):\/\/(user-images.githubusercontent.com)([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/g
);
return listOfImages || [];
};
exports.getTaskDescription = (description) => {
if (description) {
const contextText = getContext(description).trim();
if (!contextText) {
return description;
}
const clubhouseLink = getClubhouseLink(description);
const allImages = getAllImages(description);
return `${clubhouseLink ? `${clubhouseLink}\n` : ""}${contextText}${
allImages && allImages.length > 0
? `\n${allImages.map((path) => `screenshot: ${path}`).join("\n")}`
: ""
}`;
}
return "";
};