@@ -7,7 +7,6 @@ import Map from "./components/map";
77import Overlay from "./components/overlay" ;
88import { ErrorBoundaryAlert } from "./components/ui/error-alert" ;
99import { useStore } from "./store" ;
10- import { getCurrentHref } from "./utils/href" ;
1110import { uploadFile } from "./utils/upload" ;
1211
1312function MapFallback ( { error } : { error : unknown } ) {
@@ -36,32 +35,18 @@ export default function App() {
3635 const { db } = useDuckDb ( ) ;
3736
3837 useEffect ( ( ) => {
39- if ( href ) {
40- history . pushState ( null , "" , "?href=" + href ) ;
41- document . title = "stac-map | " + href ;
42- } else {
43- history . pushState ( null , "" , location . pathname ) ;
44- document . title = "stac-map" ;
45- }
38+ if ( href && new URLSearchParams ( location . search ) . get ( "href" ) !== href )
39+ history . replaceState ( null , "" , "?href=" + href ) ;
40+ else history . replaceState ( null , "" , null ) ;
4641 } , [ href ] ) ;
4742
4843 useEffect ( ( ) => {
4944 function handlePopState ( ) {
50- setHref ( getCurrentHref ( ) ?? "" ) ;
45+ setHref ( new URLSearchParams ( location . search ) . get ( "href" ) ) ;
5146 }
5247 window . addEventListener ( "popstate" , handlePopState ) ;
5348
54- if ( getCurrentHref ( ) ) {
55- try {
56- new URL ( getCurrentHref ( ) ) ;
57- } catch {
58- history . pushState ( null , "" , location . pathname ) ;
59- }
60- }
61-
62- return ( ) => {
63- window . removeEventListener ( "popstate" , handlePopState ) ;
64- } ;
49+ return ( ) => window . removeEventListener ( "popstate" , handlePopState ) ;
6550 } , [ setHref ] ) ;
6651
6752 useEffect ( ( ) => {
0 commit comments