Skip to content

Commit

Permalink
Fixes ampersand escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
IainSAP committed Sep 20, 2024
1 parent 81c9158 commit 80a80ea
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const validateMetadataFile = async (
}

try {
const metadata = await readFile(path, 'utf-8');
metadata.replace(/ & /g, ' & ');
let metadata = await readFile(path, 'utf-8');
metadata = metadata.replace(/ & /g, ' & ');
const { validationMsg, version } = validateODataVersion(metadata, odataVersion);
if (validationMsg) {
return validationMsg;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="NorthwindModel"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Category">
<Key>
<PropertyRef Name="CategoryID" />
</Key>
<Property Name="CategoryID" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"
xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" FixedLength="false" Unicode="true" />
<Property Name="Description" Type="Edm.String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="Picture" Type="Edm.Binary" MaxLength="Max" FixedLength="false" />
<NavigationProperty Name="Products" Relationship="NorthwindModel.FK_Products_Categories" ToRole="Products" FromRole="Categories" />
</EntityType>
<Annotation Term="UI.Facets">
<Collection>
<Record Type="UI.CollectionFacet">
<PropertyValue Property="Label" String="Terms & Conditions" />
</Record>
</Collection>
</Annotation>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import path from 'path';
import { validateMetadataFile } from '../../../../src/prompts/datasources/metadata-file/validators';

describe('metadata valiadtors', () => {
test('validateMetadataFile', async () => {
const testXmlPath = path.join(__dirname, 'fixtures/validatorTest.xml');
expect(await validateMetadataFile(testXmlPath)).toMatchObject({
version: '2',
metadata: expect.stringContaining('Terms &amp; Conditions') //Ensure that the & is replaced with &amp;
});
});
});

0 comments on commit 80a80ea

Please sign in to comment.