feat(parser): Text#toHTML (#300)

Added support to render Text nodes as HTML for use in web applications.
This commit is contained in:
Daniel Wykerd
2023-02-01 21:27:59 +02:00
committed by GitHub
parent f62c66db39
commit e82e23dfbb
4 changed files with 62 additions and 2 deletions

View File

@@ -94,6 +94,17 @@ class NavigationEndpoint extends YTNode {
throw new Error('Expected an api_url, but none was found, this is a bug.');
return actions.execute(this.metadata.api_url, { ...this.payload, ...args });
}
toURL(): string | undefined {
if (!this.metadata.url)
return undefined;
if (!this.metadata.page_type)
return undefined;
return (
this.metadata.page_type === 'WEB_PAGE_TYPE_UNKNOWN' ?
this.metadata.url : `https://www.youtube.com${this.metadata.url}`
);
}
}
export default NavigationEndpoint;