Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

[Resolvido] NodeJS - indexOf Erro

$
0
0
Boa noite, estou a programar um script em NodeJS e preciso descobrir se existe numa string determinado texto, neste caso "http" ou "https".
Para tal, tentei usar a função indexOf mas retorna-me erro.
Existe outra forma de o fazer?
Erro retornado: TypeError: Cannot call method 'indexOf' of undefined

Código (Javascript):
if (str.indexOf("http://") > -1 || str.indexOf("https://") > -1) {
domain=handshakeData.headers.referer.replace('http://','').replace('https://','').split(/[/?#]/)[0];
}

Melhores cumprimentos.

Viewing all articles
Browse latest Browse all 14700