11/**
22 * Copyright (c) 2021 Hengyang Zhang
3- *
3+ *
44 * This software is released under the MIT License.
55 * https://opensource.org/licenses/MIT
66 */
@@ -9,8 +9,8 @@ import { SUFFIX_HOST_MAP } from "./constant/remain-host"
99
1010/**
1111 * Test whether the url belongs to the browser
12- *
13- * @param url
12+ *
13+ * @param url
1414 */
1515export function isBrowserUrl ( url : string ) {
1616 return / ^ c h r o m e .* ?: \/ \/ .* $ / . test ( url )
@@ -30,8 +30,8 @@ const isNotValidPort = (portStr: string) => {
3030
3131/**
3232 * Test whether the host is ip or ip and port
33- *
34- * @param host
33+ *
34+ * @param host
3535 */
3636export function isIpAndPort ( host : string ) {
3737 host = host . trim ( )
@@ -49,8 +49,8 @@ export function isIpAndPort(host: string) {
4949
5050/**
5151 * Test whether the host is a valid host
52- *
53- * @param host
52+ *
53+ * @param host
5454 */
5555export function isValidHost ( host : string ) {
5656 if ( ! host ) return false
@@ -70,7 +70,7 @@ export function isValidHost(host: string) {
7070
7171/**
7272 * Test whether the host is a valid virtual host
73- *
73+ *
7474 * github.com/ = false
7575 * github.com = false
7676 * github.com/sheepzh = true
@@ -80,25 +80,26 @@ export function isValidHost(host: string) {
8080 * github.com/sheepzh? = false
8181 * github.com/sheepzh?a=1 = false
8282 * http://github.com/123 = false
83- *
83+ *
8484 * @since 1.6.0
8585 */
8686export function isValidVirtualHost ( host : string ) {
87+ console . log ( host )
8788 if ( ! host ) return false
8889 if ( host . includes ( '?' ) || host . includes ( '=' ) || host . includes ( ":" ) ) return false
8990 // Can't ends with /
9091 if ( host . endsWith ( '/' ) ) return false
91- const segs = host . split ( '/' )
92+ const segments = host . split ( '/' )
9293 // Can't be normal host
93- if ( segs . length === 1 ) return false
94- if ( ! isValidHost ( segs [ 0 ] ) ) return false
94+ if ( segments . length === 1 ) return false
95+ if ( ! isValidHost ( segments [ 0 ] ) ) return false
9596 return true
9697}
9798
9899/**
99- * Judge virtual host fastly
100- *
101- * @param host
100+ * Judge virtual host fast
101+ *
102+ * @param host
102103 * @returns T/F
103104 */
104105export function judgeVirtualFast ( host : string ) : boolean {
@@ -156,14 +157,14 @@ export function extractFileHost(url: string): string {
156157}
157158
158159/**
159- * Judge whether homepage
160+ * Judge whether homepage
160161 * e.g.
161162 * 1. https://baidu.com/ = true
162163 * 2. http://baidu.com = true
163164 * 3. www.baidu.com = true
164165 * 4. https://baidu.com/a = false
165166 * 5. http://qq.com?a=1 = false
166- *
167+ *
167168 * @since 0.5.0
168169 */
169170export function isHomepage ( url : string ) {
0 commit comments