Skip to content

Commit

Permalink
#2 Added URL
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHedley committed Dec 12, 2020
1 parent 3264945 commit bef3593
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
102 changes: 102 additions & 0 deletions src/Utility-Blazor/Pages/Url.razor
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&param=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);
}

}
5 changes: 5 additions & 0 deletions src/Utility-Blazor/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<span class="oi oi-code" aria-hidden="true"></span> Url Encode
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="url">
<span class="oi oi-code" aria-hidden="true"></span> Url
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="guid">
<span class="oi oi-code" aria-hidden="true"></span> Guid
Expand Down

0 comments on commit bef3593

Please sign in to comment.