-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix opening links without http and https #640
Open
Dmitry-VF
wants to merge
8
commits into
develop
Choose a base branch
from
feature/LinkLabelFix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4b237b9
Fix opening links without http and https
Dmitry-VF d7c04ee
fix logic a little
ceo1647 9362cfb
fix label action
ceo1647 ff33787
Fix linklabel url building logic
Dmitry-VF 1ca8766
Reduce repeating and improve readability
Dmitry-VF 63ef35c
Fix to open both kind of links website and application
Dmitry-VF ced9dc1
add test
ceo1647 7f10be4
little fixes
ceo1647 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,7 @@ public IInputElement? CommandTarget | |
/// <summary> | ||
/// ClickEvent | ||
/// </summary> | ||
[Category("Behavior")] | ||
[Category("Behavior")] | ||
public static readonly RoutedEvent? ClickEvent; | ||
|
||
/// <summary> | ||
|
@@ -214,7 +214,7 @@ public event RoutedEventHandler? Click | |
/// <summary> | ||
/// RequestNavigateEvent | ||
/// </summary> | ||
[Category("Behavior")] | ||
[Category("Behavior")] | ||
public static readonly RoutedEvent? RequestNavigateEvent; | ||
|
||
/// <summary> | ||
|
@@ -339,8 +339,32 @@ private static void OpenBrowserBehaviorImpl(object sender, RoutedEventArgs args) | |
return; | ||
} | ||
|
||
var destinationUrl = hyperlinkSender?.NavigateUri ?? linklabelSender?.Url; | ||
if (destinationUrl is null || string.IsNullOrEmpty(destinationUrl.ToString())) | ||
var uri = linklabelSender?.Url; | ||
if (uri is null) | ||
{ | ||
return; | ||
} | ||
|
||
if (!uri.IsAbsoluteUri || !(uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase) | ||
|| uri.Scheme.StartsWith("https", StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
string modifiedUriString; | ||
if (uri.IsAbsoluteUri) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe there is a way not to check it twice |
||
{ | ||
modifiedUriString = $"https://{uri}"; | ||
} | ||
else | ||
{ | ||
var relativePart = uri.GetComponents(UriComponents.PathAndQuery | UriComponents.Fragment, | ||
UriFormat.UriEscaped); | ||
modifiedUriString = $"https://{relativePart}"; | ||
} | ||
|
||
uri = new Uri(modifiedUriString); | ||
} | ||
|
||
var destinationUrl = hyperlinkSender?.NavigateUri ?? uri; | ||
if (string.IsNullOrEmpty(destinationUrl.ToString())) | ||
{ | ||
return; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase) || uri.Scheme.StartsWith("https", StringComparison.OrdinalIgnoreCase) === uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Catel even has StartsWithIgnoreCase and StartsWithAnyIgnoreCase