fix: normalizing spaces for authors/dek/title (#31)

* fix: normalizing spaces for authors/dek/title
pull/32/head^2
Adam Pash 8 years ago committed by GitHub
parent 9a23b24a89
commit cfe7f34be4

@ -1,7 +1,10 @@
import { normalizeSpaces } from 'utils/text';
import { CLEAN_AUTHOR_RE } from './constants';
// Take an author string (like 'By David Smith ') and clean it to
// just the name(s): 'David Smith'.
export default function cleanAuthor(author) {
return author.replace(CLEAN_AUTHOR_RE, '$2').trim();
return normalizeSpaces(
author.replace(CLEAN_AUTHOR_RE, '$2').trim()
);
}

@ -1,5 +1,8 @@
import { stripTags } from 'utils/dom';
import { excerptContent } from 'utils/text';
import {
excerptContent,
normalizeSpaces,
} from 'utils/text';
import { TEXT_LINK_RE } from './constants';
@ -18,5 +21,5 @@ export default function cleanDek(dek, { $, excerpt }) {
// not a good dek - bail.
if (TEXT_LINK_RE.test(dekText)) return null;
return dekText.trim();
return normalizeSpaces(dekText.trim());
}

@ -1,4 +1,5 @@
import { stripTags } from 'utils/dom';
import { normalizeSpaces } from 'utils/text';
import { TITLE_SPLITTERS_RE } from './constants';
import { resolveSplitTitle } from './index';
@ -21,5 +22,5 @@ export default function cleanTitle(title, { url, $ }) {
}
// strip any html tags in the title text
return stripTags(title, $).trim();
return normalizeSpaces(stripTags(title, $).trim());
}

Loading…
Cancel
Save