Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/app/models/place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ const seedData = async (directory: string) => {

const typeRegex = /^.*\//;
const parseOsgb = (val: string) => parseInt(val, 10) || "";
const stripBom = (val: string) => val.replace(/^\uFEFF/, "");
const transformExceptions = {
code: stripBom,
northings: parseOsgb,
eastings: parseOsgb,
min_eastings: parseOsgb,
Expand Down
12 changes: 12 additions & 0 deletions test/place.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ describe("Place Model", () => {
const result = await query(q);
assert.equal(result.rows[0].count, placesEntriesCount);
});

it("strips BOM characters from code field", async () => {
// BOM (U+FEFF) can appear at start of CSV files and pollute first field
const q = `SELECT code FROM ${Place.relation.relation}`;
const result = await query(q);
result.rows.forEach((row) => {
assert.isFalse(
row.code.startsWith("\uFEFF"),
`code "${row.code}" should not start with BOM character`
);
});
});
});

describe("#populateLocation", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/postcode.regression.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe("Postcode data regression testing", function () {
admin_district: "Channel Islands",
parish: null,
admin_county: null,
admin_ward: null,
admin_ward: "Channel Islands (pseudo)",
ccg: null,
ccg_code: null,
nuts: null,
Expand Down