import { parseRedisQuery } from "./common" ; import { BasicRedisSocketOptions as Options } from "../basic_options" ; import { ParseError } from "../../errors" ; import { getScheme , parseUri , Scheme } from "../../uri" ; import * as _ from "underscore" ; param uri returns throws export const parse = ( uri ) : Options => { const protocol = getScheme ( uri ) ; if ( protocol !== Scheme . RedisSocket && protocol !== Scheme . RedisSocketSecure ) { throw new ParseError ( `unrecognized scheme "${ protocol }"` ) ; } const parsed = parseUri ( uri ) ; const path = parsed . path ; return { path : validatePath ( path ) , protocol , ... parseRedisQuery ( parsed ) , } ; } ; param path returns throws const validatePath = ( path ) : string => { if ( /^[^\0]+$/ . test ( path ) !== true ) { throw new ParseError ( `invalid path "${ path }"` ) ; } return path ; } ;