How to use the replace function from url

Find comprehensive JavaScript url.replace code examples handpicked from public code repositorys.

9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
if (typeof url !== 'string' && typeof url !== 'object') {
	throw new Error(`Parameter \`url\` must be a string or object, not ${typeof url}`);
}

if (typeof url === 'string') {
	url = url.replace(/^unix:/, 'http://$&');
	url = urlParseLax(url);

	if (url.auth) {
		throw new Error('Basic authentication must be done with auth option');
fork icon0
star icon0
watch icon1

14
15
16
17
18
19
20
21
22
23
24


function getHeaders(url, options, ctx, customHeader) {
    var headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        Referer: "https://www.facebook.com/",
        Host: url.replace("https://", "").split("/")[0],
        Origin: "https://www.facebook.com",
        "User-Agent": options.userAgent,
        Connection: "keep-alive"
    };
fork icon0
star icon0
watch icon1