handle wrong github url

pull/5370/head
Aniket-Engg 2 years ago committed by Aniket
parent 7f19eb0df0
commit 8ad9dcb223
  1. 13
      libs/remix-ui/workspace/src/lib/actions/index.ts

@ -103,10 +103,15 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
} }
} else if (route.endsWith('.sol')) { } else if (route.endsWith('.sol')) {
if (route.includes('blob')) route = route.replace('/blob', '') if (route.includes('blob')) route = route.replace('/blob', '')
const response: AxiosResponse = await axios.get(`https://raw.githubusercontent.com${route}`) let response: AxiosResponse
let content try {
if (response.status === 200) { response = await axios.get(`https://raw.githubusercontent.com${route}`)
content = response.data } catch (error) {
plugin.call('notification', 'toast', `cound not find ${route} on GitHub`)
await basicWorkspaceInit(workspaces, workspaceProvider)
}
if (response && response.status === 200) {
const content = response.data
await createWorkspaceTemplate('github-code-sample', 'code-template') await createWorkspaceTemplate('github-code-sample', 'code-template')
plugin.setWorkspace({ name: 'github-code-sample', isLocalhost: false }) plugin.setWorkspace({ name: 'github-code-sample', isLocalhost: false })
dispatch(setCurrentWorkspace('github-code-sample')) dispatch(setCurrentWorkspace('github-code-sample'))

Loading…
Cancel
Save