Repository URL to install this package:
|
Version:
7.0.0-alpha.3 ▾
|
import { isObj, isBrowser, isString, EMPTY_STRING } from 'exotic'
// const matchProtocol = /^(?:[a-z]+:)?/
const matchProtocol = /^(?:[a-z]+:)/
const hasProtocol = (x: string) => matchProtocol.test(x)
function isFullyQualifiedWebAddress(address: string): boolean {
return hasProtocol(address)
}
function isRelativeWebAddress(address: string): boolean {
return address.startsWith('/') || isFullyQualifiedWebAddress(address) === false
}
/**
* @TODO isInOurRoutes
*/
// function isinOurRoutes(address: string) {
// // check if it matches
// }
function isStringifiedParams(x: string): boolean {
if (!isString(x)) {
return false
} else if (x.includes('=')) {
return true
} else if (x.startsWith('?')) {
return true
} else if (x.startsWith('#')) {
return true
} else {
return false
}
}
const isHash = (to: any): to is string => isString(to) && to.startsWith('#')
export {
isRelativeWebAddress,
isFullyQualifiedWebAddress,
hasProtocol,
isHash,
isStringifiedParams,
}