Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toUnicode(parsed.hostname);
} catch (er) { /**/ }
}
}
return mdurl.decode(mdurl.format(parsed));
}
var url = mdurl.parse(String(url_str), true);
// urls without host and protocol, e.g. "example.org/foo"
if (!url.protocol && !url.slashes && !url.hostname) {
url = mdurl.parse('//' + url_str, true);
}
try {
if (url.hostname) {
url.hostname = punycode.toUnicode(url.hostname);
}
} catch (e) {}
// Decode url-encoded characters
//
if (url.auth) url.auth = mdurl.decode(url.auth);
if (url.hash) url.hash = mdurl.decode(url.hash);
if (url.search) url.search = mdurl.decode(url.search);
if (url.pathname) url.pathname = mdurl.decode(url.pathname);
// Omit protocol if it's http, https or mailto
//
if (url.protocol && url.protocol.match(/^(https?|mailto):$/)) {
url.protocol = null;
url.slashes = null;
} else if (url.slashes) {
url.slashes = null;
}
return elide_url(url, max_length);
}
// urls without host and protocol, e.g. "example.org/foo"
if (!url.protocol && !url.slashes && !url.hostname) {
url = mdurl.parse('//' + url_str, true);
}
try {
if (url.hostname) {
url.hostname = punycode.toUnicode(url.hostname);
}
} catch (e) {}
// Decode url-encoded characters
//
if (url.auth) url.auth = mdurl.decode(url.auth);
if (url.hash) url.hash = mdurl.decode(url.hash);
if (url.search) url.search = mdurl.decode(url.search);
if (url.pathname) url.pathname = mdurl.decode(url.pathname);
// Omit protocol if it's http, https or mailto
//
if (url.protocol && url.protocol.match(/^(https?|mailto):$/)) {
url.protocol = null;
url.slashes = null;
} else if (url.slashes) {
url.slashes = null;
}
return elide_url(url, max_length);
}
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toUnicode(parsed.hostname);
} catch (er) { /**/ }
}
}
return mdurl.decode(mdurl.format(parsed));
}
function loadPermalink() {
if (!location.hash) { return; }
var cfg, opts;
try {
if (/^#md3=/.test(location.hash)) {
cfg = JSON.parse(mdurl.decode(location.hash.slice(5), mdurl.decode.componentChars));
} else if (/^#md64=/.test(location.hash)) {
cfg = JSON.parse(window.atob(location.hash.slice(6)));
} else if (/^#md=/.test(location.hash)) {
cfg = JSON.parse(decodeURIComponent(location.hash.slice(4)));
} else {
return;
}
if (_.isString(cfg.source)) {
$('.source').val(cfg.source);
}
} catch (__) {
return;
function i(e) {
var t = f.parse(e, true);
if (t.hostname && (!t.protocol || y.indexOf(t.protocol) >= 0)) {
try {
t.hostname = m.toUnicode(t.hostname);
} catch (n) {}
}
return f.decode(f.format(t));
}
fixDecodedURI (node) {
if (
node &&
node.children.length === 1 &&
typeof node.children[0] === 'string'
) {
const { innerText, href } = node
node.innerText = mdurl.decode(href) === innerText ? href : innerText
}
}
fixDecodedURI (node) {
if (
node &&
node.children.length === 1 &&
typeof node.children[0] === 'string'
) {
const { innerText, href } = node
node.innerText = mdurl.decode(href) === innerText ? href : innerText
}
}