79333337

Date: 2025-01-06 14:27:58
Score: 1
Natty:
Report link

You can remove last '/' and trailing string without using split function. Just modify the Regex a bit.

const url = 'https://example.com/';
console.log(url.replace(/^(?:https?:\/\/)?(?:www\.)?|\/.*$/i, ""));

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: RPJaisawal