mirror of https://github.com/ghostfolio/ghostfolio
195 changed files with 4233 additions and 3313 deletions
@ -0,0 +1,20 @@ |
|||
import { getOidcDiscoveryUrl } from './oidc.helper'; |
|||
|
|||
describe('getOidcDiscoveryUrl', () => { |
|||
it.each([ |
|||
[ |
|||
'https://auth.example.com', |
|||
'https://auth.example.com/.well-known/openid-configuration' |
|||
], |
|||
[ |
|||
'https://auth.example.com/', |
|||
'https://auth.example.com/.well-known/openid-configuration' |
|||
], |
|||
[ |
|||
'https://auth.example.com/application/o/ghostfolio/', |
|||
'https://auth.example.com/application/o/ghostfolio/.well-known/openid-configuration' |
|||
] |
|||
])('creates the discovery URL for %s', (issuer, expected) => { |
|||
expect(getOidcDiscoveryUrl(issuer)).toBe(expected); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,4 @@ |
|||
export function getOidcDiscoveryUrl(issuer: string) { |
|||
// Remove trailing slashes
|
|||
return `${issuer.replace(/\/+$/, '')}/.well-known/openid-configuration`; |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,28 @@ |
|||
import { getDateFnsLocale } from '@ghostfolio/common/helper'; |
|||
|
|||
import { |
|||
differenceInSeconds, |
|||
formatDistanceToNowStrict, |
|||
parseISO |
|||
} from 'date-fns'; |
|||
|
|||
export function formatRelativeTime({ |
|||
date, |
|||
language |
|||
}: { |
|||
date: string; |
|||
language?: string; |
|||
}) { |
|||
if (date) { |
|||
const distanceString = formatDistanceToNowStrict(parseISO(date), { |
|||
addSuffix: true, |
|||
locale: getDateFnsLocale(language) |
|||
}); |
|||
|
|||
return Math.abs(differenceInSeconds(parseISO(date), new Date())) < 60 |
|||
? $localize`just now` |
|||
: distanceString; |
|||
} |
|||
|
|||
return ''; |
|||
} |
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue