In JavaScript, you can use the URL constructor to parse the URL and then access the desired path. Here's an example:

const url = new URL('https://github.com/test%3Efrew?ew332432=321423');
const path = url.pathname;

console.log(path); // Output: /test%3Efrew

The URL constructor takes the URL as a parameter and allows you to access different components of the URL, such as the protocol, hostname, pathname, query parameters, etc. In this case, we are interested in the pathname property, which represents the path of the URL.


原文地址: https://www.cveoy.top/t/topic/pvNV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录