From 015753960182a113c06138e449b45ca0a88a0cbf Mon Sep 17 00:00:00 2001 From: Falco Peijnenburg Date: Mon, 28 Aug 2017 20:06:23 +0200 Subject: [PATCH] Added more info to URI returned by getCurrentURI Specifically: filled in uriScheme and uriFragment --- ghcjs-src/Miso/Subscription/History.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ghcjs-src/Miso/Subscription/History.hs b/ghcjs-src/Miso/Subscription/History.hs index a8622a58..51743404 100644 --- a/ghcjs-src/Miso/Subscription/History.hs +++ b/ghcjs-src/Miso/Subscription/History.hs @@ -41,11 +41,11 @@ getCurrentURI = getURI getURI :: IO URI {-# INLINE getURI #-} getURI = do - URI <$> pure mempty + URI <$> do unpack <$> getProtocol <*> pure Nothing <*> do Prelude.drop 1 . unpack <$> getPathName <*> do unpack <$> getSearch - <*> pure mempty + <*> do unpack <$> getHash -- | Pushes a new URI onto the History stack pushURI :: URI -> IO () @@ -107,6 +107,12 @@ foreign import javascript unsafe "$r = window.location.pathname;" foreign import javascript unsafe "$r = window.location.search;" getSearch :: IO JSString +foreign import javascript unsafe "$r = window.location.hash;" + getHash :: IO JSString + +foreign import javascript unsafe "$r = window.location.protocol;" + getProtocol :: IO JSString + foreign import javascript unsafe "window.addEventListener('popstate', $1);" onPopState :: Callback (IO ()) -> IO ()