• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript url.URL类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中url.URL的典型用法代码示例。如果您正苦于以下问题:TypeScript URL类的具体用法?TypeScript URL怎么用?TypeScript URL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了URL类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getWebAppUrl

function getWebAppUrl() {
  const queryParams = new url.URLSearchParams();
  queryParams.set('version', electron.app.getVersion());

  // Set queryParams from environment variables.
  if (process.env.SB_IMAGE) {
    queryParams.set('image', process.env.SB_IMAGE);
    console.log(`Will install Shadowbox from ${process.env.SB_IMAGE} Docker image`);
  }
  if (process.env.SB_METRICS_URL) {
    queryParams.set('metricsUrl', process.env.SB_METRICS_URL);
    console.log(`Will use metrics url ${process.env.SB_METRICS_URL}`);
  }
  if (process.env.SENTRY_DSN) {
    queryParams.set('sentryDsn', process.env.SENTRY_DSN);
    console.log(`Will use sentryDsn url ${process.env.SENTRY_DSN}`);
  }
  if (debugMode) {
    queryParams.set('outlineDebugMode', 'true');
    console.log(`Enabling Outline debug mode`);
  }

  // Append arguments to URL if any.
  const webAppUrl = new url.URL('outline://web_app/index.html');
  webAppUrl.search = queryParams.toString();
  const webAppUrlString = webAppUrl.toString();
  console.log('Launching web app from ' + webAppUrlString);
  return webAppUrlString;
}
开发者ID:fang2x,项目名称:outline-server,代码行数:29,代码来源:index.ts


示例2: URL

 return new Promise<string>((resolve, reject) => {
   try {
     const parsedUrl = new URL(url);
     const header = this.authenticator.getHeader();
     parsedUrl.searchParams.set('Authorization', header.Authorization);
     resolve(parsedUrl.toString());
   } catch (e) {
     reject(e);
   }
 });
开发者ID:wix,项目名称:media-platform-js-sdk,代码行数:10,代码来源:http-client.ts


示例3: updateWebsite

async function updateWebsite(spinner: Ora): Promise<number> {
  spinner.start();

  if (await hasChanges()) {
    spinner.fail('Please reset your local changes before running this script');
    return 1;
  }

  let pkg = await readPackage();
  let latestVersion = await getLatestVersion(pkg);
  let currentRevision = await gitRevParse('HEAD');
  let remote = 'origin';

  spinner.text = 'Building';
  await run('yarn', ['build']);

  spinner.text = 'Switching to website branch';
  let githubToken = process.env['GH_TOKEN'];

  if (githubToken) {
    let remoteURL = new URL((await run('git', ['remote', 'get-url', remote])).stdout.trim());
    remoteURL.username = githubToken;
    remoteURL.password = '';
    await run('git', ['remote', 'set-url', remote, remoteURL.toString()]);
  }

  await run('git', ['fetch', remote, `+refs/heads/gh-pages:refs/remotes/${remote}/gh-pages`]);
  await run('git', ['reset', '--hard', `${remote}/gh-pages`]);

  spinner.text = 'Creating browser build';
  await run('browserify',[
    '--standalone', 'esnext',
    '--require', `./${pkg.main}`,
    '--outfile', 'esnext.js'
  ]);

  if (await hasChanges()) {
    if (commit) {
      spinner.text = 'Pushing changes to website';
      await run('git', ['commit', '-av', '-m', `chore: update to v${latestVersion}`]);
      await run('git', ['push', '--force', remote, 'HEAD:gh-pages']);
      spinner.succeed('Website published');
    } else {
      console.log((await run('git', ['diff'])).stdout);
    }
  } else {
    spinner.succeed('Already up to date');
  }

  await run('git', ['reset', '--hard', currentRevision]);

  return 0;
}
开发者ID:alangpierce,项目名称:esnext,代码行数:53,代码来源:update-website.ts


示例4: redirect

function redirect(response: express.Response, baseURL: URL, params: {[key: string]: any}) {
  let url = new URL(baseURL.toString());
  for (let key in params) {
    if (!params.hasOwnProperty(key)) {
      continue;
    }
    if (typeof params[key] !== 'undefined') {
      url.searchParams.set(key, params[key].toString());
    }
  }
  response.redirect(url.toString());
}
开发者ID:jdiazmx,项目名称:gateway,代码行数:12,代码来源:oauth_controller.ts


示例5: map

    map(partialUrl => {
      if (!partialUrl) {
        partialUrl = 'https://registry.npmjs.org/';
      }
      const partial = url.parse(partialUrl);
      let fullUrl = new url.URL(`http://${partial.host}/${packageName.replace(/\//g, '%2F')}`);
      try {
        const registry = new url.URL(partialUrl);
        registry.pathname = (registry.pathname || '')
            .replace(/\/?$/, '/' + packageName.replace(/\//g, '%2F'));
        fullUrl = new url.URL(url.format(registry));
      } catch {}

      logger.debug(
        `Getting package.json from '${packageName}' (url: ${JSON.stringify(fullUrl)})...`,
      );

      return fullUrl.toString();
    }),
开发者ID:iwe7,项目名称:devkit,代码行数:19,代码来源:npm.ts


示例6: return

 return (function _annotate(obj: any, scope: string): any {
   if (isRef(obj)) {
     const uri = new URL(obj.$ref, scope);
     uri.hash = '#'
     getMeta(obj).refs.add(uri.toString());
     obj[__meta].scope = normalizeUri(scope);
   } else {
     if (typeof obj.$id === 'string') {
       if (!obj.$id || obj.$id === '#') {
         throw new SyntaxError(`Invalid identifier ${obj.$id}`);
       }
       const id = new URL(obj.$id, scope);
       if (id.hash) {
         if (!id.hash.substr(1).match(LII_RE)) {
           throw new SyntaxError(`Invalid identifier ${obj.$id}`);
         }
       } else {
         id.hash = '#';
       }
       obj[__meta].scope = id.toString();
       obj[__meta].registry[obj[__meta].scope] = obj;
       obj[__meta].root = obj;
     } else {
       obj[__meta].scope = normalizeUri(scope);
     }
     const keys = Object.keys(obj);
     for (let key of keys) {
       const next = obj[key];
       if (next !== null && typeof next === 'object' && !isAnnotated(next)) {
         const meta = getMeta(obj);
         next[__meta] = {
           registry: meta.registry,
           refs: meta.refs,
           parent: obj,
           root: meta.root
         }
         _annotate(next, `${meta.scope}/${escape(key)}`);
       }
     }
   }
   return obj;
 })(obj, options.scope);
开发者ID:vivocha,项目名称:jsonref,代码行数:42,代码来源:meta.ts


示例7: addUrl

  public addUrl(url: URL | string) {
    if (typeof url === 'string') {
      if (!url.match(protocolRegExp)) {
         url = `${this.defaultProtocol()}${url}`;
      }

      url = new URL(url);
    }

    this.urls.push(url);
  }
开发者ID:chrisseg,项目名称:vscode-azure-blockchain-ethereum,代码行数:11,代码来源:Consortium.ts


示例8: createWindow

function createWindow() {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 360, height: 640, resizable: false, icon: iconPath});

  const pathToIndexHtml = path.join(__dirname, '..', 'www', 'electron_index.html');
  const webAppUrl = new url.URL(`file://${pathToIndexHtml}`);

  // Debug mode, etc.
  const queryParams = new url.URLSearchParams();
  if (debugMode) {
    queryParams.set('debug', 'true');
  }
  webAppUrl.search = queryParams.toString();

  const webAppUrlAsString = webAppUrl.toString();

  console.log(`loading web app from ${webAppUrlAsString}`);
  mainWindow.loadURL(webAppUrlAsString);

  // Emitted when the window is closed.
  mainWindow.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });

  // TODO: is this the most appropriate event?
  mainWindow.webContents.on('did-finish-load', () => {
    interceptShadowsocksLink(process.argv);
  });

  // The client is a single page app - loading any other page means the
  // user clicked on one of the Privacy, Terms, etc., links. These should
  // open in the user's browser.
  mainWindow.webContents.on('will-navigate', (event: Event, url: string) => {
    shell.openExternal(url);
    event.preventDefault();
  });
}
开发者ID:fang2x,项目名称:outline-client,代码行数:40,代码来源:index.ts


示例9: getBoolean

        function getBoolean(): boolean { return false; }
        const urlUrl = url.parse('http://example.com/?hello=world', getBoolean());
        if (typeof(urlUrl.query) === 'string') {
            queryStr = urlUrl.query;
        } else if (urlUrl.query) {
            helloQuery = urlUrl.query['hello'];
        }
    }

    {
        const ascii: string = url.domainToASCII('espaĂąol.com');
        const unicode: string = url.domainToUnicode('xn--espaol-zwa.com');
    }

    {
        let myURL = new url.URL('https://theuser:[email protected]:81/foo/path?query=string#bar');
        assert.equal(myURL.hash, '#bar');
        assert.equal(myURL.host, 'example.org:81');
        assert.equal(myURL.hostname, 'example.org');
        assert.equal(myURL.href, 'https://theuser:[email protected]:81/foo/path?query=string#bar');
        assert.equal(myURL.origin, 'https://example.org:81');
        assert.equal(myURL.password, 'thepwd');
        assert.equal(myURL.username, 'theuser');
        assert.equal(myURL.pathname, '/foo/path');
        assert.equal(myURL.port, "81");
        assert.equal(myURL.protocol, "https:");
        assert.equal(myURL.search, "?query=string");
        assert.equal(myURL.toString(), 'https://theuser:[email protected]:81/foo/path?query=string#bar');
        assert(myURL.searchParams instanceof url.URLSearchParams);

        myURL.host = 'example.org:82';
开发者ID:Lavoaster,项目名称:DefinitelyTyped,代码行数:31,代码来源:node-tests.ts


示例10: executeAsync

 public async executeAsync() {
     const response = new HttpResponseMessage(MOVED_TEMPORARILY);
     response.headers.location = this.location.toString();
     return response;
 }
开发者ID:inversify,项目名称:inversify-express-utils,代码行数:5,代码来源:RedirectResult.ts



注:本文中的url.URL类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript url.URLSearchParams类代码示例发布时间:2022-05-25
下一篇:
TypeScript url.resolve函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap