Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
Why new URL() method removes one part of my url passed as a base url

I created a snippet to show the issue below

I have the following values to create my URL

const baseUrl = 'https://s3.xxx.xxx.com/xyz.xxx.xxx.twilio';
const accessCode = 'accesscode_he-ar_IL.mp3';

When I run new URL() the result is https://s3.xxx.xxx.com/accesscode_he-ar_IL.mp3

Why the middle part is removed as xyz.xxx.xxx.twilio

I have no clue why the method removes part of my URL and this results in a fail for me as I need to get data from that path.

const baseUrl = 'https://s3.xxx.xxx.com/xyz.xxx.xxx.twilio';
const accessCode = 'accesscode_he-ar_IL.mp3';

const res = new URL(accessCode, baseUrl);

console.log(res);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You forgot to add an extra / at the end of your baseUrl : const baseUrl = 'https://s3.xxx.xxx.com/xyz.xxx.xxx.twilio/'

const baseUrl = 'https://s3.xxx.xxx.com/xyz.xxx.xxx.twilio/';
const accessCode = 'accesscode_he-ar_IL.mp3';

const res = new URL(accessCode, baseUrl);

console.log(res);

The URL() method replace the current page (which in your case was xyz.xxx.xxx.twilio) by the new page passed through the access code.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!