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

102
Views
React How to make an <a> tag always treat the href value as an absolute path

In React I'm trying to have an tag that that redirect the user to dynamically set value like this:

<a href={url} >{url}</a>

The problem is that the 'url' can have 'https' or not. for example if the value of url is : com.com then the application treat the 'url' value as relative and append the value to localhost : localhost:3000/path/com.com

How Can I make sure the value given to is treated like absolute value.

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

0

You can write a simple function that checks if the URL starts with "http/https", and if not just add it to the URL, something like that:

https://codesandbox.io/s/competent-glitter-pr5gw?file=/src/App.js:264-268

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!