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

TypeScript url_resolver.UrlResolver类代码示例

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

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



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

示例1: describe

 describe('UrlResolver', () => {
   var resolver = new UrlResolver();
   it('should add a relative path to the base url', () => {
     expect(resolver.resolve('http://www.foo.com', 'bar')).toEqual('http://www.foo.com/bar');
     expect(resolver.resolve('http://www.foo.com/', 'bar')).toEqual('http://www.foo.com/bar');
     expect(resolver.resolve('http://www.foo.com', './bar')).toEqual('http://www.foo.com/bar');
     expect(resolver.resolve('http://www.foo.com/', './bar')).toEqual('http://www.foo.com/bar');
   });
   it('should replace the base path', () => {
     expect(resolver.resolve('http://www.foo.com/baz', 'bar')).toEqual('http://www.foo.com/bar');
     expect(resolver.resolve('http://www.foo.com/baz', './bar')).toEqual('http://www.foo.com/bar');
   });
   it('should append to the base path', () => {
     expect(resolver.resolve('http://www.foo.com/baz/', 'bar')).toEqual('http://www.foo.com/baz/bar');
     expect(resolver.resolve('http://www.foo.com/baz/', './bar')).toEqual('http://www.foo.com/baz/bar');
   });
   it('should support ".." in the path', () => {
     expect(resolver.resolve('http://www.foo.com/baz/', '../bar')).toEqual('http://www.foo.com/bar');
     expect(resolver.resolve('http://www.foo.com/1/2/3/', '../../bar')).toEqual('http://www.foo.com/1/bar');
     expect(resolver.resolve('http://www.foo.com/1/2/3/', '../biz/bar')).toEqual('http://www.foo.com/1/2/biz/bar');
     expect(resolver.resolve('http://www.foo.com/1/2/baz', '../../bar')).toEqual('http://www.foo.com/bar');
   });
   it('should ignore the base path when the url has a scheme', () => {
     expect(resolver.resolve('http://www.foo.com', 'http://www.bar.com')).toEqual('http://www.bar.com');
   });
   it('should throw when the url start with "/"', () => {
     expect(() => {
       resolver.resolve('http://www.foo.com/1/2', '/test');
     }).toThrowError();
   });
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:31,代码来源:url_resolver_spec.ts


示例2: it

 it('should support absolute urls', () => {
   expect(resolver.resolve('http://www.foo.com', '/bar')).toEqual('http://www.foo.com/bar');
   expect(resolver.resolve('http://www.foo.com/', '/bar')).toEqual('http://www.foo.com/bar');
   expect(resolver.resolve('http://www.foo.com/baz', '/bar'))
       .toEqual('http://www.foo.com/bar');
   expect(resolver.resolve('http://www.foo.com/baz/', '/bar'))
       .toEqual('http://www.foo.com/bar');
 });
开发者ID:goderbauer,项目名称:angular,代码行数:8,代码来源:url_resolver_spec.ts


示例3: it

 it('should support ".." in the path', () => {
   expect(resolver.resolve('http://www.foo.com/baz/', '../bar'))
       .toEqual('http://www.foo.com/bar');
   expect(resolver.resolve('http://www.foo.com/1/2/3/', '../../bar'))
       .toEqual('http://www.foo.com/1/bar');
   expect(resolver.resolve('http://www.foo.com/1/2/3/', '../biz/bar'))
       .toEqual('http://www.foo.com/1/2/biz/bar');
   expect(resolver.resolve('http://www.foo.com/1/2/baz', '../../bar'))
       .toEqual('http://www.foo.com/bar');
 });
开发者ID:AsherBarak,项目名称:angular,代码行数:10,代码来源:url_resolver_spec.ts


示例4: SyncAsyncResult

  _inlineImports(cssText: string, baseUrl: string,
                 inlinedUrls: List<string>): SyncAsyncResult<string> {
    var partIndex = 0;
    var parts = StringWrapper.split(cssText, _importRe);

    if (parts.length === 1) {
      // no @import rule found, return the original css
      return new SyncAsyncResult(cssText, null);
    }

    var promises = [];

    while (partIndex < parts.length - 1) {
      // prefix is the content before the @import rule
      var prefix = parts[partIndex];
      // rule is the parameter of the @import rule
      var rule = parts[partIndex + 1];
      var url = _extractUrl(rule);
      if (isPresent(url)) {
        url = this._urlResolver.resolve(baseUrl, url);
      }
      var mediaQuery = _extractMediaQuery(rule);
      var promise;

      if (isBlank(url)) {
        promise = PromiseWrapper.resolve(`/* Invalid import rule: "@import ${rule};" */`);
      } else if (ListWrapper.contains(inlinedUrls, url)) {
        // The current import rule has already been inlined, return the prefix only
        // Importing again might cause a circular dependency
        promise = PromiseWrapper.resolve(prefix);
      } else {
        ListWrapper.push(inlinedUrls, url);
        promise = PromiseWrapper.then(this._xhr.get(url), (rawCss) => {
          // resolve nested @import rules
          var inlinedCss = this._inlineImports(rawCss, url, inlinedUrls);
          if (isPresent(inlinedCss.asyncResult)) {
            // wait until nested @import are inlined
            return inlinedCss.asyncResult.then(
                (css) => {return prefix + this._transformImportedCss(css, mediaQuery, url) + '\n'});
          } else {
            // there are no nested @import, return the css
            return prefix + this._transformImportedCss(inlinedCss.syncResult, mediaQuery, url) +
                   '\n';
          }
        }, (error) => `/* failed to import ${url} */\n`);
      }
      ListWrapper.push(promises, promise);
      partIndex += 2;
    }

    return new SyncAsyncResult(null, PromiseWrapper.all(promises).then(function(cssParts) {
      var cssText = cssParts.join('');
      if (partIndex < parts.length) {
        // append then content located after the last @import rule
        cssText += parts[partIndex];
      }
      return cssText;
    }));
  }
开发者ID:baraksu,项目名称:angular,代码行数:59,代码来源:style_inliner.ts


示例5:

    return StringWrapper.replaceAllMapped(cssText, re, (m) => {
      var pre = m[1];
      var url = StringWrapper.replaceAll(m[2], _quoteRe, '');
      var post = m[3];

      var resolvedUrl = this._resolver.resolve(baseUrl, url);

      return pre + "'" + resolvedUrl + "'" + post;
    });
开发者ID:AsherBarak,项目名称:angular,代码行数:9,代码来源:style_url_resolver.ts


示例6:

    return StringWrapper.replaceAllMapped(cssText, re, (m) => {
      var pre = m[1];
      var originalUrl = m[2];
      if (RegExpWrapper.test(_dataUrlRe, originalUrl)) {
        // Do not attempt to resolve data: URLs
        return m[0];
      }
      var url = StringWrapper.replaceAll(originalUrl, _quoteRe, '');
      var post = m[3];

      var resolvedUrl = this._resolver.resolve(baseUrl, url);

      return pre + "'" + resolvedUrl + "'" + post;
    });
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:14,代码来源:style_url_resolver.ts


示例7: expect

 () => {
   expect(resolver.resolve('http://www.foo.com', 'http://www.bar.com'))
       .toEqual('http://www.bar.com');
 })
开发者ID:AsherBarak,项目名称:angular,代码行数:4,代码来源:url_resolver_spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript xhr.XHR类代码示例发布时间:2022-05-25
下一篇:
TypeScript title.Title类代码示例发布时间: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