Explorar el Código

Cleanup URL before sending it to native

jherve hace 1 año
padre
commit
ffe4aa8f2f
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      src/Background.purs

+ 7 - 0
src/Background.purs

@@ -20,6 +20,7 @@ import ExampleWebExt.RuntimeMessage (RuntimeMessage(..), onRuntimeMessageAddList
 import ExampleWebExt.Storage (clearAllJobs, getJobsPath, storeJob)
 import LinkedIn.Jobs.JobOffer (JobOffer(..))
 import LinkedIn.Output.Types (Output(..))
+import Web.URL as URL
 
 main :: Effect Unit
 main = do
@@ -51,6 +52,7 @@ contentScriptMessageHandler
   where
     maybeMsg (JobOffer jo) = ado
       location <- jo.location
+      url <- cleanUpUrl url
     in NativeMessageVisitedJobPage {
       url: url,
       jobTitle: jo.title,
@@ -72,6 +74,11 @@ contentScriptMessageHandler _ m (MessageSender {tab, id}) = do
 
   debug msg
 
+cleanUpUrl :: String -> Maybe String
+cleanUpUrl u = do
+  url <- URL.fromAbsolute u
+  pure $ URL.toString $ URL.setSearch "" url
+
 nativeMessageHandler ∷ NativeMessage → Effect Unit
 nativeMessageHandler (NativeMessageJobOfferList job_offers) = do
   clearAllJobs