-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support of regexp named groups. #270
- Loading branch information
Krasimir Tsonev
committed
Feb 2, 2021
1 parent
2478e63
commit ea14b64
Showing
15 changed files
with
68 additions
and
13 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 8.8.4 | ||
|
||
Support of regexp named groups. #270 | ||
|
||
## 8.8.3 | ||
|
||
Fixing a bug with notFound handler hooks. #271 | ||
|
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,7 @@ | ||
{ | ||
"name": "navigo-example-basic-spa", | ||
"private": true, | ||
"scripts": { | ||
"start": "node ./server.js" | ||
} | ||
} |
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,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Navigo</title> | ||
<link href="/styles.css" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<div> | ||
<a href="/xyz/foobar" data-navigo>Click me</a> | ||
</div> | ||
<hr /> | ||
<div id="content"></div> | ||
<script src="/navigo.js"></script> | ||
<script> | ||
window.addEventListener("load", () => { | ||
const router = new Navigo("/"); | ||
const render = (content) => | ||
(document.querySelector("#content").innerHTML = content); | ||
|
||
router | ||
.on(/xyz\/(?<myName>[0-9a-z]{4,8})$/, (match) => { | ||
render(`<p>${match.data.myName}</p>`); | ||
}) | ||
.resolve(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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,11 @@ | ||
const express = require("express"); | ||
const app = express(); | ||
const port = 3000; | ||
const { staticAssets, serveFile } = require("../utils/server"); | ||
|
||
staticAssets(app); | ||
app.get("*", serveFile(__dirname + "/page.html")); | ||
|
||
app.listen(port, () => { | ||
console.log(`Example app listening at http://localhost:${port}`); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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