cspanvideos
Version:
A small api for gathering video information from CSPAN for a particular legislator.
30 lines (22 loc) • 685 B
text/typescript
export function formatPersonName(name: string, withSpace?: boolean): string|Error {
let split, finalName;
if ( !name || typeof name !== "string" ) {
return new Error("Must have a name present or it must be a string!");
}
split = name.trim().split(" ");
// Checking if there is a middle initial;
if ( split.length === 3 ) {
split.splice(1, 1);
}
// For when we need to handle malformed urls.
finalName = !withSpace
? split.join("").toLowerCase()
: split.join(" ");
return finalName;
}
export function formatEmbedURL(url: string): string {
let furl:string|string[] = url.split("/");
furl.pop();
furl = furl.join("/");
return furl;
}