File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
/** Check if a website is up */
2
2
export async function isUp ( url : string ) : Promise < boolean > {
3
- const hostname = encodeURIComponent ( ( new URL ( url ) ) . hostname ) ;
3
+ const host = encodeURIComponent ( ( new URL ( url ) ) . host ) ;
4
4
const result : {
5
5
"domain" : string ;
6
6
"port" : number ;
7
7
"status_code" : 1 | 2 | 3 ;
8
8
"response_ip" : string ;
9
9
"response_code" : number ;
10
10
"response_time" : number ;
11
- } = await ( await fetch ( `https://isitup.org/${ hostname } .json` ) )
11
+ } = await ( await fetch ( `https://isitup.org/${ host } .json` ) )
12
12
. json ( ) ;
13
13
return result . status_code === 1 ;
14
14
}
Original file line number Diff line number Diff line change @@ -10,3 +10,13 @@ Deno.test("should be down", async (): Promise<void> => {
10
10
false ,
11
11
) ;
12
12
} ) ;
13
+
14
+ /**
15
+ * The official website of deno is: https://deno.land/
16
+ * Website remote address: 172.67.163.168:443
17
+ * The official website of Deno does not allow users to access content through IP addresses,
18
+ * but in some cases, I may need this method to test my personal server.
19
+ */
20
+ Deno . test ( "deno remote address test" , async ( ) : Promise < void > => {
21
+ assertEquals ( await isUp ( "http://172.67.163.168:443" ) , true ) ;
22
+ } )
You canβt perform that action at this time.
0 commit comments