diff --git a/src/pages/profile/loader.ts b/src/pages/profile/loader.ts
index aecb15d..f3ac4c0 100644
--- a/src/pages/profile/loader.ts
+++ b/src/pages/profile/loader.ts
@@ -4,9 +4,10 @@ import { LoaderFunctionArgs, redirect } from 'react-router-dom'
import { appRoutes, getProfilePageRoute } from 'routes'
import { store } from 'store'
import { MuteLists, UserProfile } from 'types'
-import { log, LogType } from 'utils'
+import { log, LogType, npubToHex } from 'utils'
export interface ProfilePageLoaderResult {
+ profilePubkey: string
profile: UserProfile
isBlocked: boolean
isOwnProfile: boolean
@@ -24,10 +25,25 @@ export const profileRouteLoader =
const { nprofile } = params
let profilePubkey: string | undefined
try {
- const value = nprofile
- ? nip19.decode(nprofile as `nprofile1${string}`)
- : undefined
- profilePubkey = value?.data.pubkey
+ // Decode if it starts with nprofile1
+ if (nprofile?.startsWith('nprofile1')) {
+ const value = nprofile
+ ? nip19.decode(nprofile as `nprofile1${string}`)
+ : undefined
+ profilePubkey = value?.data.pubkey
+ } else if (nprofile?.startsWith('npub1')) {
+ // Try to get hex from the npub and encode it to nprofile
+ const value = npubToHex(nprofile)
+ if (value) {
+ return redirect(
+ getProfilePageRoute(
+ nip19.nprofileEncode({
+ pubkey: value
+ })
+ )
+ )
+ }
+ }
} catch (error) {
// Silently ignore and redirect to home or logged in user
log(true, LogType.Error, 'Failed to decode nprofile.', error)
@@ -57,6 +73,7 @@ export const profileRouteLoader =
// Empty result
const result: ProfilePageLoaderResult = {
+ profilePubkey: profilePubkey,
profile: {},
isBlocked: false,
isOwnProfile: false,
diff --git a/src/styles/dotsSpinner.module.scss b/src/styles/dotsSpinner.module.scss
new file mode 100644
index 0000000..772dfa8
--- /dev/null
+++ b/src/styles/dotsSpinner.module.scss
@@ -0,0 +1,18 @@
+.loading::after {
+ content: '.';
+ animation: dots 1.5s steps(4, end) infinite;
+}
+
+@keyframes dots {
+ 0%,
+ 20% {
+ content: '.\00a0\00a0';
+ }
+ 40% {
+ content: '..\00a0';
+ }
+ 60%,
+ 100% {
+ content: '...';
+ }
+}