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

Remove extra slash in blockexporer url #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/checkout/src/views/TransactionStatus/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState, useEffect } from 'react'
import {
ArrowDownIcon,
Box,
Expand All @@ -11,9 +10,6 @@ import {
CloseIcon,
truncateAddress
} from '@0xsequence/design-system'
import TimeAgo from 'timeago-react'
import { formatUnits, Hex, PublicClient } from 'viem'
import { usePublicClient } from 'wagmi'
import {
CollectibleTileImage,
useContractInfo,
Expand All @@ -22,6 +18,10 @@ import {
TRANSACTION_CONFIRMATIONS_DEFAULT
} from '@0xsequence/kit'
import { findSupportedNetwork } from '@0xsequence/network'
import { useState, useEffect } from 'react'
import TimeAgo from 'timeago-react'
import { formatUnits, Hex, PublicClient } from 'viem'
import { usePublicClient } from 'wagmi'

import { HEADER_HEIGHT } from '../../constants'
import { useTransactionStatusModal } from '../../hooks'
Expand Down Expand Up @@ -82,7 +82,7 @@ export const TransactionStatus = () => {
onError
} = transactionStatusSettings!
const networkConfig = findSupportedNetwork(chainId)
const blockExplorerUrl = `${networkConfig?.blockExplorer?.rootUrl}/tx/${txHash}`
const blockExplorerUrl = `${networkConfig?.blockExplorer?.rootUrl}tx/${txHash}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd expect rootUrl not to have the trailing slash. And this path would stay the same /txt/..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that it shouldn't be there... But removing it is a breaking change that will break a bunch of applications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rootUrl.replace(/\/+$/, ''); ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a small pathJoin utility to handle these cases then we don't need to care

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export function join(...paths: string[]): string {
  return paths
    .map(path => path.trim())
    .filter(Boolean)
    .join('/')
    .replace(/(?<!:)\/{2,}/g, '/')
}

const [startTime] = useState(new Date())
const [status, setStatus] = useState<TxStatus>('pending')
Expand Down
Loading