Skip to content

Commit

Permalink
fix: Don't trim trailing slashes from safe apps
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Oct 9, 2024
1 parent 946c662 commit e77f5d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/safe-apps/AddCustomAppModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import useAsync from '@/hooks/useAsync'
import useDebounce from '@/hooks/useDebounce'
import { fetchSafeAppFromManifest } from '@/services/safe-apps/manifest'
import { SAFE_APPS_EVENTS, trackSafeAppEvent } from '@/services/analytics'
import { isSameUrl, trimTrailingSlash } from '@/utils/url'
import { isSameUrl } from '@/utils/url'
import CustomAppPlaceholder from './CustomAppPlaceholder'
import CustomApp from './CustomApp'
import { useShareSafeAppUrl } from '@/components/safe-apps/hooks/useShareSafeAppUrl'
Expand Down Expand Up @@ -70,7 +70,7 @@ export const AddCustomAppModal = ({ open, onClose, onSave, safeAppsList }: Props
}

const appUrl = watch('appUrl')
const debouncedUrl = useDebounce(trimTrailingSlash(appUrl || ''), 300)
const debouncedUrl = useDebounce(appUrl || '', 300)

const [safeApp, manifestError] = useAsync<SafeAppData | undefined>(() => {
if (!isValidURL(debouncedUrl)) return
Expand Down
5 changes: 2 additions & 3 deletions src/services/safe-apps/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,18 @@ const fetchSafeAppFromManifest = async (
appUrl: string,
currentChainId: string,
): Promise<SafeAppDataWithPermissions> => {
const normalizedAppUrl = trimTrailingSlash(appUrl)
const appManifest = await fetchAppManifest(appUrl)

if (!isAppManifestValid(appManifest)) {
throw new Error('Invalid Safe App manifest')
}

const iconUrl = getAppLogoUrl(normalizedAppUrl, appManifest)
const iconUrl = getAppLogoUrl(appUrl, appManifest)

return {
// Must satisfy https://docs.djangoproject.com/en/5.0/ref/models/fields/#positiveintegerfield
id: Math.round(Math.random() * 1e9 + 1e6),
url: normalizedAppUrl,
url: appUrl,
name: appManifest.name,
description: appManifest.description,
accessControl: { type: SafeAppAccessPolicyTypes.NoRestrictions },
Expand Down

0 comments on commit e77f5d2

Please sign in to comment.