Skip to content

Commit

Permalink
Merge pull request #163 from ghiculescu/crash-non-url
Browse files Browse the repository at this point in the history
Don't attempt to navigate to invalid URLs
  • Loading branch information
jayohms authored Jul 21, 2021
2 parents 9fff983 + 37676b4 commit 6c1ea13
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import dev.hotwire.turbo.fragments.TurboWebFragment
import dev.hotwire.turbo.session.TurboSession
import dev.hotwire.turbo.session.TurboSessionNavHostFragment
import dev.hotwire.turbo.visit.TurboVisitOptions
import java.net.URL

/**
* The primary interface that a navigable Fragment implements to provide the library with
Expand Down Expand Up @@ -129,7 +130,12 @@ interface TurboNavDestination {
* Turbo navigation flow).
*/
fun shouldNavigateTo(newLocation: String): Boolean {
return true
return try {
URL(newLocation)
true
} catch (e: java.net.MalformedURLException) {
false
}
}

/**
Expand Down

0 comments on commit 6c1ea13

Please sign in to comment.