How to compare two URL Strings ?

I have two global Strings, each one represents a URL that at certain times assume equal values, that is, the same URL for both Strings. I want to create an when they are different. When they are equal nothing should happen.

I tried the three methods below, none of them worked.

Does anyone know how this piece of code has to look to work ?

Thanks

url = https://agamenon.com/s/vfaqly96fqss7y9/test.txt
urlsave = https://agamenon.com/s/eh6sotgjn8q5drz/test.txt

if(url.equals(urlsalva) != 0)   {  
    Serial.println("THE URL'S ARE DIFFERENT");
  } else {
    Serial.println("THE URL'S ARE THE SAME");    
  }

if(url.compareTo(urlsalva) != 0)   {  
    Serial.println("THE URL'S ARE DIFFERENT");
  } else {
    Serial.println("THE URL'S ARE THE SAME");    
  }

if(url != urlsalva)   {  
    Serial.println("THE URL'S ARE DIFFERENT");
  } else {
    Serial.println("THE URL'S ARE THE SAME");    
  }

I think I found the solution (the error)

False alarm.

The two URLs are different but the code prints on the serial monitor the phrase that they ARE EQUAL.

And when they are the same, treat them as if they were different. I mean, you're not comparing anything.

url I get like this: url = client.get String();

It is saved url I read from an SD card like this: urlsaved = myFile.readString();

And at the beginning I have String url,urlsalva;

So both would be Strings. Or could they be const char and that's why the comparison isn't working ?

Google will tell you! [https://docs.arduino.cc/built-in-examples/strings/StringComparisonOperators]

This and twenty other sites. But thank you.

Decided to measure the length of the two Strings I needed to compare. The one coming from a GET request was 64 characters long and the one I read from the SD card was 66. Oops, but both look the same on the serial monitor.

That's when I noticed that to write the URL to the SD card I was using the function;

myFile.println(url);

This ln was creating an extra line. It could only have been that because I eliminated the ln and now the comparison using the common operator == works. The comparison in the ten consecutive tests I did works both to confirm and to say when they are different.

A detail that made me spend hours and hours researching.