0

My problem is the following. I have an application that asks the user to insert a Url on Wikipedia. For example the user inserts :

URLInserted = "http://en.wikipedia.org/wiki/USA". 

Inserting this URL opens the page

TrueURl = "http://en.wikipedia.org/wiki/United_States" 

that is the real URL of the Unites States page on Wikipedia. Once the page is loaded I save the current URL into a variable. When I print the string contained in the variable the URL that is printed is the URLInserted and NOT TrueURL. I would like that the URL that I save into my variable is the TrueURL of the United States page and not the URLInserted by the user. How can I solve this issue? This is the function that I use to get the URL :

currentUrl = String(describing: WebView.request?.mainDocumentURL)       
brandonscript
  • 68,675
  • 32
  • 163
  • 220

1 Answers1

1

Wikipedia redirects you to the page the user inserted. If you compare the two, the path/USA is redirected from path/United_States.

I'm not sure what you're trying to solve. One idea: you can look at this post for how to listen for redirects from the web view.

Community
  • 1
  • 1
E. Bogren
  • 118
  • 1
  • 9