New Sep 19, 2024

Is there a way to validate and allow only https url's using .isUri i.e. without using Regex in JavaScript?

Libraries, Frameworks, etc. All from Newest questions tagged reactjs - Stack Overflow View Is there a way to validate and allow only https url's using .isUri i.e. without using Regex in JavaScript? on stackoverflow.com

Is there a way to validate "https" url's using .isUri in javascript (it should return true only for https url's)? (any other method should be fine except regex)

https://test.com //true
test.com // false
http://test.com // false
http://test // false

code snippet (below works great but it returns true for http url's, instead it should return false for http url's): -

const validateUrl = (url) => {
  return !!validUrl.isUri(url);
};

Thanks

Scroll to top