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

fix: Don't trim trailing slashes from safe apps #4348

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
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
Loading