Skip to content

Commit

Permalink
fix(endpoint-micropub): remove support for deprecated slug property
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Aug 26, 2020
1 parent 04b27ec commit dbed056
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/endpoint-micropub/lib/microformats.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const getPublishedProperty = mf2 => {
* @returns {Array} Array containing slug value
*/
export const getSlugProperty = (mf2, separator) => {
const suggested = mf2.properties['mp-slug'] || mf2.properties.slug;
const suggested = mf2.properties['mp-slug'];
const {name} = mf2.properties;

let string;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"type": ["h-entry"],
"properties": {
"name": ["I ate a cheese sandwich, which was nice."],
"slug": [""]
"mp-slug": [""]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"type": ["h-entry"],
"properties": {
"name": ["I ate a cheese sandwich, which was nice."],
"slug": ["cheese-sandwich"]
"mp-slug": ["cheese-sandwich"]
}
}
18 changes: 3 additions & 15 deletions packages/endpoint-micropub/tests/lib/microformats.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,32 +185,20 @@ test('Gets date by using current date', t => {
t.true(isValid(parseISO(result[0])));
});

test('Derives slug from `slug` property', t => {
const mf2 = JSON.parse(getFixture('slug-provided.json'));
const slug = getSlugProperty(mf2, '-');
t.is(slug[0], 'cheese-sandwich');
});

test('Derives slug from `mp-slug` property', t => {
const mf2 = JSON.parse(getFixture('mp-slug-provided.json'));
const mf2 = JSON.parse(getFixture('slug-provided.json'));
const slug = getSlugProperty(mf2, '-');
t.is(slug[0], 'cheese-sandwich');
});

test('Derives slug from unslugified `mp-slug` property', t => {
const mf2 = JSON.parse(getFixture('mp-slug-provided-unslugified.json'));
const mf2 = JSON.parse(getFixture('slug-provided-unslugified.json'));
const slug = getSlugProperty(mf2, '-');
t.is(slug[0], 'cheese-sandwich');
});

test('Derives slug, ignoring empty `slug` property', t => {
const mf2 = JSON.parse(getFixture('slug-provided-empty.json'));
const slug = getSlugProperty(mf2, '-');
t.is(slug[0], 'i-ate-a-cheese-sandwich');
});

test('Derives slug, ignoring empty `mp-slug` property', t => {
const mf2 = JSON.parse(getFixture('mp-slug-provided-empty.json'));
const mf2 = JSON.parse(getFixture('slug-provided-empty.json'));
const slug = getSlugProperty(mf2, '-');
t.is(slug[0], 'i-ate-a-cheese-sandwich');
});
Expand Down

0 comments on commit dbed056

Please sign in to comment.