Skip to content

Commit

Permalink
Remove pointy brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
LMacPhail committed Nov 28, 2023
1 parent b479bb5 commit c599926
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = express();
app.use(cors());

// Configuration for the proxy
const API_SERVICE_URL = "https://api.futurelabourmps.com/A3:AT65";
const API_SERVICE_URL = "https://api.futurelabourmps.com/A3:AT70";

app.use(
"/api",
Expand Down
7 changes: 7 additions & 0 deletions src/data/utils/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ describe("extractLinks", () => {
expect(formatted.content).toEqual(["Something something"]);
});

const pointyBrackets = "Something something <https://something.com>";
it("splits a simple content <link> format", () => {
const formatted = extractLinks(basic);
expect(formatted.link?.[0]).toEqual("https://something.com");
expect(formatted.content).toEqual(["Something something"]);
});

const sandwich = "Something something https://something.com | Bleep bloop";
it("splits a simple content <link> format", () => {
const formatted = extractLinks(sandwich);
Expand Down
4 changes: 3 additions & 1 deletion src/data/utils/string.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const urlRegex = /(https?:\/\/[^ ]*)/;
const urlRegex = /(https?:\/\/[^ ]*)/g;
const bracketRegex = /[<>]/g;

/**
* Given a content string including a hyperlink in <> parentheses, separates into content and link
Expand All @@ -13,6 +14,7 @@ export const extractLinks = (
}

const content = raw
.replace(bracketRegex, " ")
.replace(urlRegex, "")
.split("|")
.filter((string) => string !== "")
Expand Down
6 changes: 0 additions & 6 deletions src/data/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const expectedValues = [
positive: undefined,
},
},
notes: "",
},
{
name: "Roisin McKenna Favier",
Expand Down Expand Up @@ -161,7 +160,6 @@ const expectedValues = [
positive: undefined,
},
},
notes: "",
},
{
name: "Martin Rhodes",
Expand Down Expand Up @@ -229,7 +227,6 @@ const expectedValues = [
positive: undefined,
},
},
notes: "",
},
{
name: "Michael Shanks MP",
Expand Down Expand Up @@ -299,7 +296,6 @@ const expectedValues = [
positive: undefined,
},
},
notes: "",
},
{
name: "John Grady",
Expand Down Expand Up @@ -369,7 +365,6 @@ const expectedValues = [
positive: undefined,
},
},
notes: "",
},
{
name: "Gordon McKee",
Expand Down Expand Up @@ -430,7 +425,6 @@ const expectedValues = [
positive: undefined,
},
},
notes: "",
},
];

Expand Down

0 comments on commit c599926

Please sign in to comment.