Fix instanceUrl not being optional
This commit is contained in:
parent
b5970446b4
commit
fbfe4a646a
|
@ -9,7 +9,7 @@ export interface State {
|
||||||
defaultServerUrl: string
|
defaultServerUrl: string
|
||||||
additionalStylesheets: string[] // TODO (wvffle): Ensure it's not nullable
|
additionalStylesheets: string[] // TODO (wvffle): Ensure it's not nullable
|
||||||
}
|
}
|
||||||
instanceUrl: string
|
instanceUrl?: string
|
||||||
knownInstances: string[]
|
knownInstances: string[]
|
||||||
nodeinfo: unknown | null // TODO (wvffle): Get nodeinfo type from swagger automatically
|
nodeinfo: unknown | null // TODO (wvffle): Get nodeinfo type from swagger automatically
|
||||||
settings: Settings
|
settings: Settings
|
||||||
|
@ -132,7 +132,7 @@ const store: Module<State, RootState> = {
|
||||||
getters: {
|
getters: {
|
||||||
absoluteUrl: (state) => (relativeUrl: string) => {
|
absoluteUrl: (state) => (relativeUrl: string) => {
|
||||||
if (relativeUrl.startsWith('http')) return relativeUrl
|
if (relativeUrl.startsWith('http')) return relativeUrl
|
||||||
if (state.instanceUrl.endsWith('/') && relativeUrl.startsWith('/')) {
|
if (state.instanceUrl?.endsWith('/') && relativeUrl.startsWith('/')) {
|
||||||
relativeUrl = relativeUrl.slice(1)
|
relativeUrl = relativeUrl.slice(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,8 @@ const store: Module<State, RootState> = {
|
||||||
return instanceUrl + relativeUrl
|
return instanceUrl + relativeUrl
|
||||||
},
|
},
|
||||||
domain: (state) => {
|
domain: (state) => {
|
||||||
|
if (!state.instanceUrl) return null
|
||||||
|
|
||||||
const url = state.instanceUrl
|
const url = state.instanceUrl
|
||||||
const parser = document.createElement('a')
|
const parser = document.createElement('a')
|
||||||
parser.href = url
|
parser.href = url
|
||||||
|
|
Loading…
Reference in New Issue