function parseURL(url) { var a = URL.parse(url); return { source: url, protocol: a.protocol?a.protocol.replace(':',''):"http", host: a.hostname, port: a.port, query: a.search?a.search:"", params: (function(){ var ret = {}, seg = (a.search?a.search:"").replace(/^\?/,'').split('&'), len = seg.length, i = 0, s; for (;i<len;i++) { if (!seg[i]) { continue; } s = seg[i].split('='); ret[s[0]] = s[1]; } return ret; })(), file:((a.pathname?a.pathname.match(/\/([^\/?#]+)$/i):"") || [,''])[1], hash: a.hash?a.hash.replace('#',''):"", path: a.pathname?a.pathname.replace(/^([^\/])/,'/$1'):"", relative: ((a.href.match(/tps?:\/\/[^\/]+(.+)/)) || [,''])[1], segments: a.pathname?a.pathname.replace(/^\//,'').split('/'):"" }; }
/** * @param {http.IncomingMessage} req * @return {string} */ function formatRequestUrl(req) { const parsed = url.parse(req.url); return url.format({ protocol: req.connection.encrypted ? 'https' : 'http', host: req.headers.host, pathname: parsed.pathname, search: parsed.search }); }
// determine the stripped registry url function getStrippedRegistryUrl() { const registryUrl = xible.Config.getValue('registry.url'); const parsedRegistryUrl = url.parse(registryUrl); delete parsedRegistryUrl.protocol; delete parsedRegistryUrl.auth; delete parsedRegistryUrl.query; delete parsedRegistryUrl.search; delete parsedRegistryUrl.hash; return url.resolve(url.format(parsedRegistryUrl), '.'); }
// if there's a request for a file and that file exists, // serve that file. Otherwise, redirect to root route const catchAll = (req, res, next) => { let fileName = url.parse(req.url); fileName = fileName.href.split(fileName.search).join(''); const fileExists = fs.existsSync(folder + fileName); if (!fileExists && fileName.indexOf('browser-sync-client') < 0) { req.url = '/'; } return next(); }
function parseURL(strURL) { var path = url.parse(strURL); log('href:', path.href); log('protocol:', path.protocol); log('auth:', path.auth); log('hostname:', path.hostname); log('port:', path.port); log('host', path.host); log('pathname:', path.pathname); log('search:', path.search); log('query:', path.query); log('hash:', path.hash); log('URL parse:', path.pathname.split('/')); log('QueryString parse:', qs.parse(path.query)); }
lucius.register('role:auth,cmd:authorizeStorage', async function (connector, args) { // args: id, trashpointId, type, container return connector.input(args) .use(async function (image, responder) { const blobName = `${image.trashpointId ? image.trashpointId : image.eventId}_${image.id}.jpg`; const sas = azureStorage.getBlobSAS(image.container, blobName, 10); const server = azureStorage.getServer(); const urlInfo = url.parse(sas); delete urlInfo.search; delete urlInfo.query; const response = { sas: sas, id: image.id, name: blobName, server, url: url.format(urlInfo), file: path.basename(urlInfo.pathname), }; return responder.success(response); }) });
fileName = fileName.href.split(fileName.search).join(""); var fileExists = fs.existsSync('./tmp/' + fileName);
static handleRSD($, url) { const myURL = urlparser.parse(url); var expiresParam = BotUtils.getUrlParameter(myURL.search, "Expires"); var expireDate = new Date(parseInt(expiresParam) * 1000); var currentDate = new Date(); if (currentDate > expireDate) { var msg = util.format(tg._localization.En.rsdLinkExpired, expireDate.toGMTString()); request.get("https://signedurl-svjhrfxmfa.now.sh/?url=" + matches[0].split("?")[0], function (error, response, body) { msg += (body) $.sendMessage(msg, { parse_mode: "html", reply_to_message_id: $.message.messageId }); }); } else { $.sendMessage(util.format(tg._localization.En.rsdLinkWarning, expireDate.toGMTString()), { parse_mode: "html", reply_to_message_id: $.message.messageId }); } }
const parseUrl = (originalUrl, airtableBaseId) => { const components = parse(originalUrl); const params = match(components.pathname); if (params === false) { const originalPath = components.path; return { proxyUrl: originalPath, tableName: false }; } const proxyUrl = '/' + compact([ params.version, airtableBaseId, params.tableName, params.recordId, components.search, ]).join('/'); return { proxyUrl, tableName: params.tableName, }; }
url = parsed.pathname + (parsed.search || '') + (parsed.hash || '');
/** * @private * @param {http.IncomingMessage} req * @return {string} */ function formatRequestUrl(req) { const parsed = url.parse(req.originalUrl); return url.format({ protocol: req.protocol, host: req.get('host'), pathname: parsed.pathname, search: parsed.search }); }
/** * @param {http.IncomingMessage} req * @return {string} */ function formatRequestUrl(req) { const parsed = url.parse(req.url); return url.format({ protocol: req.connection.encrypted ? 'https' : 'http', host: req.headers.host, pathname: parsed.pathname, search: parsed.search }); }
/** * @param {http.IncomingMessage} req * @return {string} */ function formatRequestUrl(req) { var parsed = url.parse(req.url); return url.format({ protocol: req.connection.encrypted ? 'https' : 'http', host: req.headers.host, pathname: parsed.pathname, search: parsed.search }); }
/** * @private * @param {http.IncomingMessage} req * @return {string} */ function formatRequestUrl(req) { const parsed = url.parse(req.originalUrl); return url.format({ protocol: req.protocol, host: req.get('host'), pathname: parsed.pathname, search: parsed.search }); }
fileName = fileName.href.split(fileName.search).join(""); var fileExists = fs.existsSync('./tmp/' + fileName);