Use absolute URLs to settings to avoid relative URL edge cases (#781)
* Create useAbsoluteFilePath hook * Fix "report bug" link on Error page * Replace relative URL to settings with absolute URL * Replace other absolute file URLs to use common hook * Use named const for default browser file name * Fix UI tests that now rely on useRouteLoaderData() Signed-off-by: Frank Noirot <frank@kittycad.io> --------- Signed-off-by: Frank Noirot <frank@kittycad.io>
This commit is contained in:
12
src/hooks/useAbsoluteFilePath.ts
Normal file
12
src/hooks/useAbsoluteFilePath.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { BROWSER_FILE_NAME, IndexLoaderData, paths } from 'Router'
|
||||
import { useRouteLoaderData } from 'react-router-dom'
|
||||
|
||||
export function useAbsoluteFilePath() {
|
||||
const routeData = useRouteLoaderData(paths.FILE) as IndexLoaderData
|
||||
|
||||
return (
|
||||
paths.FILE +
|
||||
'/' +
|
||||
encodeURIComponent(routeData?.project?.path || BROWSER_FILE_NAME)
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user