Skip to content

Commit

Permalink
Merge pull request #2210 from stakwork/feature/1902
Browse files Browse the repository at this point in the history
Feature/1902
  • Loading branch information
Rassl authored Sep 24, 2024
2 parents 77985bb + 17be3d4 commit a6941e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Button from '@mui/material/Button'
import clsx from 'clsx'
import moment from 'moment'
import { useEffect, useRef, useState } from 'react'
import styled from 'styled-components'
import { Divider } from '~/components/common/Divider'
Expand Down Expand Up @@ -95,7 +96,7 @@ export const Default = () => {
isPlaying={isPlaying}
label={formatLabel(key)}
togglePlay={togglePlay}
value={value}
value={key === 'date' && value ? moment(value * 1000).format('MMMM Do YYYY') : value}
/>
))}
</StyledWrapper>
Expand Down
10 changes: 5 additions & 5 deletions src/utils/apiUrlFromSwarmHost/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ describe('apiUrlFromSwarmHost', () => {
jest.restoreAllMocks()
})

it('returns "https://knowledge-graph.sphinx.chat/api" for the URL "https://second-brain.sphinx.chat"', () => {
it('returns "https://bitcoin.sphinx.chat/api" for the URL "https://second-brain.sphinx.chat"', () => {
mockWindowLocation('https://second-brain.sphinx.chat')
expect(apiUrlFromSwarmHost()).toBe('https://knowledge-graph.sphinx.chat/api')
expect(apiUrlFromSwarmHost()).toBe('https://bitcoin.sphinx.chat/api')
})

it('returns "https://knowledge-graph.sphinx.chat/api" for a URL containing "localhost"', () => {
it('returns "https://bitcoin.sphinx.chat/api" for a URL containing "localhost"', () => {
mockWindowLocation('http://localhost:3000')
expect(apiUrlFromSwarmHost()).toBe('https://knowledge-graph.sphinx.chat/api')
expect(apiUrlFromSwarmHost()).toBe('https://bitcoin.sphinx.chat/api')
})

it('returns the original URL appended with /api for a URL not containing "swarm" and not hardcoded', () => {
const nonSwarmUrl = 'https://knowledge-graph.sphinx.chat'
const nonSwarmUrl = 'https://bitcoin.sphinx.chat'

mockWindowLocation(nonSwarmUrl)
expect(apiUrlFromSwarmHost()).toBe(`${nonSwarmUrl}/api`)
Expand Down
6 changes: 3 additions & 3 deletions src/utils/apiUrlFromSwarmHost/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { origin, host } = window.location

const getUrlFormEnv = () => import.meta.env.VITE_APP_API_URL

export const API_URL = getUrlFormEnv() || apiUrlFromSwarmHost() || 'https://knowledge-graph.sphinx.chat'
export const API_URL = getUrlFormEnv() || apiUrlFromSwarmHost() || 'https://bitcoin.sphinx.chat'

export function apiUrlFromSwarmHost(): string | undefined {
// for swarm deployments, always point to "boltwall"
Expand All @@ -21,8 +21,8 @@ export function apiUrlFromSwarmHost(): string | undefined {

url = `https://${finalHost}`
}
} else if (originUrl === 'https://second-brain.sphinx.chat' || origin.includes('localhost')) {
url = 'https://knowledge-graph.sphinx.chat'
} else if (origin.includes('localhost')) {
url = 'https://bitcoin.sphinx.chat'
}

return `${url}/api`
Expand Down

0 comments on commit a6941e4

Please sign in to comment.