Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
Differentiate between youTube URLs and the file names of embedded MP4s?

I want to, in my init() function, check to see if the video is either a youtube URL or a file name.

Does this seem suitable or is there some kind of edge case I might be missing?

    function init(){
        playerSource = Document.getElementById('vid').src;
        if ( playerSource.includes("https://www.youtube") ){
            //Call to function that begins setting up YT iFrame API
        }
    }

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can validate the youtube URL using below regex.

regExp = /^(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/

Youtube has different url forms depending upon where you are taking from

Normal Url

https://www.youtube.com/watch?v=12345678901

Share Url

https://youtu.be/12345678901

Share Url with start time

https://youtu.be/12345678901?t=6

Mobile browser url

https://m.youtube.com/watch?v=12345678901&list=RD12345678901&start_radio=1

Long url

https://www.youtube.com/watch?v=12345678901&list=RD12345678901&start_radio=1&rv=smKgVuS

Long url with start time

https://www.youtube.com/watch?v=12345678901&list=RD12345678901&start_radio=1&rv=12345678901&t=38

You can check these URL validation below https://regex101.com/r/7a1lGH/1

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda