-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3264945
commit bef3593
Showing
2 changed files
with
107 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
@using System.Web; | ||
@using System.Collections.Specialized; | ||
|
||
@page "/url" | ||
|
||
<div class="container"> | ||
<div class="row"> | ||
<div class="input-group mb-3"> | ||
<input type="text" id="path" name="path" class="form-control" @bind="path"> | ||
<div class="input-group-append"> | ||
<span class="input-group-text" id="urlCount">@pathLength</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<button id="btnPathSplit" name="btnPathSplit" class="btn btn-success float-right" | ||
@onclick="Split">Split</button> | ||
</div> | ||
|
||
<br /> | ||
|
||
<!-- Hostname --> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<div class="input-group mb-3"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text">Hostname</span> | ||
</div> | ||
<input type="text" class="form-control" placeholder="hostname" aria-label="hostname" | ||
id="hostname" name="hostname" | ||
@bind="hostname" disabled> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Pathname --> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<div class="input-group mb-3"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text">Pathname</span> | ||
</div> | ||
<input type="text" class="form-control" placeholder="pathname" aria-label="pathname" | ||
id="pathname" name="pathname" | ||
@bind="pathName" disabled> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Params --> | ||
<div class="row"> | ||
<div class="col-12"> | ||
<table id="urlParams"> | ||
<thead> | ||
<tr> | ||
<th>Key</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tfoot></tfoot> | ||
<tbody> | ||
@foreach (string key in queryString) | ||
{ | ||
<tr> | ||
<td><em>@key</em></td> | ||
<td><em>@queryString[key]</em></td> | ||
</tr> | ||
} | ||
</tbody> | ||
|
||
</table> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
@code { | ||
|
||
string path; | ||
int pathLength; | ||
string hostname; | ||
string pathName; | ||
NameValueCollection queryString; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
path = "http://www.alexhedley.com/path?query=this¶m=that"; | ||
pathLength = path.Length; | ||
queryString = new NameValueCollection(); | ||
} | ||
|
||
private void Split() | ||
{ | ||
pathLength = path.Length; | ||
|
||
Uri uri = new Uri(path); | ||
hostname = uri.Host; | ||
pathName = uri.AbsolutePath; | ||
queryString = HttpUtility.ParseQueryString(uri.Query); | ||
} | ||
|
||
} |
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