To parse the URL, I advise looking at this StackOverflow topic:
https://stackoverflow.com/questions/13592236/parse-a-uri-string-into-name-value-collection
I copy and pasted part of the StackOverflow answer here, but I'm sure I'd just lose some context when I did that, so best just to follow the link and study the question and answer there.
I think, in this case, it is best to follow the template of the StackOverflow answer, rather than to write your own routine for parsing URLs, as the format of URLs can be more complicated then you expect, so using an widely accepted answer as a base will help you achieve a more robust solution.
Similarly, for the other question revealed in the thread regarding How to prevent navigation in WebView and perform some other action instead?, see:
https://stackoverflow.com/questions/15555510/javafx-stop-opening-url-in-webview-open-in-browser-instead
Note that the accepted answer advises DOM level intercepts, rather than the solution of monitoring the location property for changes and performing actions based upon that (as user
testing showed that monitoring the location property and making changes to the location in the change listener to be unreliable in some cases). The advised solution (again copied from StackOverflow) was:
The comment on the answer is also important:
"This is the best way. Add a listener on webView.getEngine().getLoadWorker().stateProperty(), check for State.SUCCEEDED, and then call the above, making sure to use the org.w3c classes where names conflict with the JavaFX namespace (as in the case of Node, Event etc.). "
Also note that the event filter calls evt.preventDefault() to stop the actioning of a default action (navigation). That seems a superior solution (to me) to trying to monitor the WebView worker state and cancel it.