Skip to content

Commit

Permalink
refactor: code style (#10462)
Browse files Browse the repository at this point in the history
  • Loading branch information
guanbinrui committed Aug 18, 2023
1 parent 9a34478 commit e2dcde4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ export const Container = memo(function Container(props: PropsWithChildren<{}>) {
})

export const Link = memo(function Anchor(props: RenderFragmentsContextType.LinkProps) {
let text = props.children
if (text.startsWith('https://mask.io')) {
text = 'Mask.io'
}
const text = props.children.startsWith('https://mask.io') ? 'Mask.io' : props.children

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
https://mask.io
' may be followed by an arbitrary host name.
return (
<MaterialLink href={props.href} fontSize="inherit">
{text}
Expand Down
4 changes: 2 additions & 2 deletions packages/mask/shared-ui/TypedMessageRender/context.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useMemo } from 'react'
import { useSubscription } from 'use-subscription'
import { emptyTransformationContext, type TransformationContext } from '@masknet/typed-message'
import {
RenderFragmentsContext,
Expand All @@ -10,8 +12,6 @@ import {
type TextResizer,
} from '@masknet/typed-message-react'
import { TypedMessageRenderRegistry } from './registry.js'
import { useSubscription } from 'use-subscription'
import { useMemo } from 'react'
import { Container, Link } from './Components/Text.js'
import { TypedMessageTransformers } from './transformer.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { RenderFragmentsContextType } from '@masknet/typed-message-react'
import { memo } from 'react'
import { Link } from '@mui/material'
import type { RenderFragmentsContextType } from '@masknet/typed-message-react'
import { useTagEnhancer } from '../../../../shared-ui/TypedMessageRender/Components/Text.js'

export const TwitterRenderFragments: RenderFragmentsContextType = {
AtLink: memo(function (props) {
const target = '/' + props.children.slice(1)
Expand Down
1 change: 1 addition & 0 deletions packages/mask/src/site-adaptors/twitter.com/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function resolveType(content: string) {
if (content.startsWith('$')) return 'cash'
return 'normal'
}

export const postContentMessageParser = (node: HTMLElement) => {
function make(node: Node): TypedMessage | TypedMessage[] {
if (node.nodeType === Node.TEXT_NODE) {
Expand Down

0 comments on commit e2dcde4

Please sign in to comment.