Skip to content

Commit

Permalink
feat: allow searching for the auto-suggested value
Browse files Browse the repository at this point in the history
  • Loading branch information
laurelmay committed Nov 28, 2024
1 parent 0e7e989 commit e9c3673
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ function getMatchesv6(ipAddress) {

async function handleLookup() {
const input = document.getElementById("lookup");
const text = input.value;
if (!input.value && input.placeholder) {
input.value = input.placeholder;
}
const text = input.value?.trim();
if (!text) {
throw new Error('A value to lookup must be provided');
}
if (text && new URL(window.location).searchParams?.get("lookup") !== text) {
const newUrl = new URL(window.location);
newUrl.search = new URLSearchParams({ lookup: text }).toString()
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>Information about AWS IP addresses</h1>
<form id="form" action="javascript:void(0);">
<label for="lookup">IP Address or Hostname</label>
<br>
<input type="text" id="lookup" name="lookup" required>
<input type="text" id="lookup" name="lookup">
<input type="submit" value="Lookup">
</form>

Expand Down

0 comments on commit e9c3673

Please # to comment.