Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
M
mirror.wales
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
PiCymru
mirror.wales
Commits
53cb590c
Commit
53cb590c
authored
Nov 11, 2018
by
Matthew Gall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added product identification by subdomain
parent
4e2b9d56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
worker.js
worker.js
+17
-2
No files found.
worker.js
View file @
53cb590c
...
...
@@ -11,9 +11,24 @@ function isInArray(value, array) {
* @param {Request} request
*/
async
function
handleRequest
(
request
)
{
path
=
new
URL
(
request
.
url
).
pathname
;
return
new
Response
(
'
Welcome to mirror.wales
'
,
{
const
PRODUCT_NAME
=
"
mirror.wales
"
let
host
=
new
URL
(
request
.
url
).
host
let
path
=
new
URL
(
request
.
url
).
pathname
;
// Now we do some syntax checking to ensure the host is valid
if
(
host
.
includes
(
`.
${
PRODUCT_NAME
}
`
)
==
false
)
{
return
new
Response
(
`You requested an invalid host. Please visit our website at
${
PRODUCT_NAME
}
`
,
{
headers
:
{
'
Content-Type
'
:
'
text/plain
'
}
})
}
// Now we fetch the subdomain from the host
let
product
=
host
.
replace
(
`.
${
PRODUCT_NAME
}
`
,
''
)
return
new
Response
(
product
,
{
headers
:
{
'
Content-Type
'
:
'
text/plain
'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment