Skip to content

Commit

Permalink
Merge pull request #218 from ONSdigital/EAR-2434-options-containing-a…
Browse files Browse the repository at this point in the history
…postrophes

Ear 2434 options containing apostrophes
  • Loading branch information
sudeepkunhis authored Jul 11, 2024
2 parents e99a66c + 4caa561 commit 659b6e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/eq_schema/block-types/Introduction/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("Introduction", () => {
{
list: [
"Data should relate to all sites in England, Scotland, Wales and Northern Ireland unless otherwise stated.",
"You can provide info estimates if actual figures aren’t available.",
"You can provide info estimates if actual figures arent available.",
"We will treat your data securely and confidentially.",
createPipedFormat("some_metadata", "metadata"),
],
Expand Down
15 changes: 11 additions & 4 deletions src/eq_schema/builders/routing2/newRoutingDestination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
const { getValueSource } = require("../../valueSource");
const { getListFromAll } = require("../../../../utils/functions/listGetters");

const { flatMap, filter } = require("lodash");
const { flatMap, filter, find } = require("lodash");

const authorConditions = {
UNANSWERED: "Unanswered",
Expand All @@ -23,9 +23,16 @@ const getOptionsFromQuestionaire = (questionnaire) => {
const getOptionValues = (optionIds, questionnaire) => {
const options = getOptionsFromQuestionaire(questionnaire);

const optionResults = optionIds.map((id) =>
filter(options, { id })[0].label.trim()
);
const optionResults = optionIds.map((id) => {
const option = find(options, { id });

const updatedLabel = option.label
.replace(/'/g, `\u2019`)
.replace(/'/g, `\u2019`)
.replace(//g, `\u2019`);

return updatedLabel.trim();
});

if (optionResults === undefined || optionResults.length < 0) {
return null;
Expand Down
18 changes: 8 additions & 10 deletions src/utils/HTMLUtils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ const getInnerHTML = (elem) =>

const removeDash = (elem) => replace(/-/g, "_", elem);

const unescapePiping = (value, isMultipleChoiceValue) => {
let updatedValue;
if (!isMultipleChoiceValue) {
updatedValue = replace(/&apos;/g, `&#39;`, value);
} else {
updatedValue = replace(/&apos;/g, `\u2019`, value);
}
updatedValue = updatedValue.trim(); //remove leading and trailing spaces

return updatedValue;
const unescapePiping = (value) => {
return value
.replace(/&apos;/g, `\u2019`)
.replace(/'/g, `\u2019`)
.replace(//g, `\u2019`)
.replace(/&#x2018;/g, `\u2019`)
.replace(/&#x2019;/g, `\u2019`)
.trim();
};

const getInnerHTMLWithPiping = (elem) => {
Expand Down

0 comments on commit 659b6e8

Please sign in to comment.