mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Use check-types helper
This commit is contained in:
parent
fb46377e2c
commit
27ebf55bb7
4 changed files with 10 additions and 28 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import plist from 'plist'
|
||||
import axios from 'axios'
|
||||
|
||||
import { isString } from './check-types.js'
|
||||
import parseMacho from './macho/index.js'
|
||||
|
||||
const prettyBytes = require('pretty-bytes')
|
||||
|
|
@ -27,24 +28,6 @@ const knownAppExtensions = new Set([
|
|||
'.app.zip'
|
||||
])
|
||||
|
||||
function isString( maybeString ) {
|
||||
return (typeof maybeString === 'string' || maybeString instanceof String)
|
||||
}
|
||||
|
||||
function isValidHttpUrl( string ) {
|
||||
if ( !isString( string ) ) return false
|
||||
|
||||
let url
|
||||
|
||||
try {
|
||||
url = new URL(string)
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
|
||||
return url.protocol === "http:" || url.protocol === "https:"
|
||||
}
|
||||
|
||||
function callWithTimeout(timeout, func) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => reject(new Error("timeout")), timeout)
|
||||
|
|
|
|||
|
|
@ -4,16 +4,20 @@ export function isString( maybeString ) {
|
|||
return (typeof maybeString === 'string' || maybeString instanceof String)
|
||||
}
|
||||
|
||||
export function isValidHttpUrl( string ) {
|
||||
if ( !isString( string ) ) return false
|
||||
export function isValidHttpUrl( maybeUrl, allowUnsecure = false ) {
|
||||
if ( !isString( maybeUrl ) ) return false
|
||||
|
||||
let url
|
||||
|
||||
try {
|
||||
url = new URL(string)
|
||||
url = new URL(maybeUrl)
|
||||
} catch (_) {
|
||||
return false
|
||||
}
|
||||
|
||||
return url.protocol === "http:" || url.protocol === "https:"
|
||||
}
|
||||
|
||||
export function isObject( maybeObject ) {
|
||||
return maybeObject === Object( maybeObject )
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue