Replace substr with slice

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-04-02 23:25:25 +02:00
parent e6ccc0e65e
commit 750a4233d3
4 changed files with 6 additions and 6 deletions

View file

@ -32,7 +32,7 @@ export const buildReactDomFromTocAst = (
const content = ( const content = (
<Fragment> <Fragment>
<ShowIf condition={toc.l > 0}> <ShowIf condition={toc.l > 0}>
<JumpAnchor href={headlineUrl} title={rawName} jumpTargetId={slug.substr(1)}> <JumpAnchor href={headlineUrl} title={rawName} jumpTargetId={slug.slice(1)}>
{rawName} {rawName}
</JumpAnchor> </JumpAnchor>
</ShowIf> </ShowIf>

View file

@ -54,7 +54,7 @@ const languages = {
*/ */
const findLanguageCode = (wantedLanguage: string): string => const findLanguageCode = (wantedLanguage: string): string =>
Object.keys(languages).find((supportedLanguage) => wantedLanguage === supportedLanguage) ?? Object.keys(languages).find((supportedLanguage) => wantedLanguage === supportedLanguage) ??
Object.keys(languages).find((supportedLanguage) => wantedLanguage.substr(0, 2) === supportedLanguage) ?? Object.keys(languages).find((supportedLanguage) => wantedLanguage.slice(0, 2) === supportedLanguage) ??
'' ''
export const LanguagePicker: React.FC = () => { export const LanguagePicker: React.FC = () => {

View file

@ -46,8 +46,8 @@ export const parseBlockquoteExtraTag = (
labelEndIndex, labelEndIndex,
valueStartIndex, valueStartIndex,
valueEndIndex, valueEndIndex,
label: line.substr(labelStartIndex, labelEndIndex - labelStartIndex), label: line.slice(labelStartIndex, labelEndIndex),
value: line.substr(valueStartIndex, valueEndIndex - valueStartIndex) value: line.slice(valueStartIndex, valueEndIndex)
} }
} }

View file

@ -26,10 +26,10 @@ export class AnchorNodePreprocessor extends TravelerNodeProcessor {
return return
} }
const isJumpMark = url.substr(0, 1) === '#' const isJumpMark = url.slice(0, 1) === '#'
if (isJumpMark) { if (isJumpMark) {
node.attribs['data-jump-target-id'] = url.substr(1) node.attribs['data-jump-target-id'] = url.slice(1)
} else { } else {
node.attribs.rel = 'noreferer noopener' node.attribs.rel = 'noreferer noopener'
node.attribs.target = '_blank' node.attribs.target = '_blank'