Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/update resource name display and fix misc bugs #294

Merged
merged 6 commits into from
Dec 16, 2020
11 changes: 10 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ export function retrieveResourceFileMetadata(fileName) {
const year = tokenArray[0];
const date = `${day} ${month} ${year}`;

const title = tokenArray.slice(3).join(' ');
const titleTokenArray = tokenArray.slice(3);
const prettifiedTitleTokenArray = titleTokenArray.map((token) => {
if (token.length < 2) return token.toUpperCase()
return token.slice(0,1).toUpperCase() + token.slice(1)
});
const prettifiedTitle = prettifiedTitleTokenArray.join(' ')

// We search for special characters which were converted to text
// Convert dollar back to $ if it is followed by any alphanumeric character
const title = prettifiedTitle.replaceAll(/dollar(?=([a-zA-Z0-9]))/gi, '$')
kwajiehao marked this conversation as resolved.
Show resolved Hide resolved

return { date, title };
}
Expand Down