GitXplorerGitXplorer
e

angular-url-format

public
0 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
b3fd8f933df9c2676f41652c5097f24fb2d66982

Merge pull request #1 from UsabilityTools/master

eerykpiast committed 11 years ago
Unverified
c875f8b685252e9969ec1dcd83f60973eab05cd7

Update bower.json

eerykpiast committed 11 years ago
Unverified
332d146cfc2d4118742a6aeb12675ffac5da5c50

Update README.md

eerykpiast committed 11 years ago
Unverified
dd15106fe316cae1352c1c0f0cae110eb2d28117

Update README.md

eerykpiast committed 11 years ago
Unverified
0bad8b3c6624fe3eccb6eadac49c4f1481d04c01

update readme

eerykpiast committed 11 years ago
Unverified
e10294e058a2f3efcb7a6bc28627774ea59c0c3d

Merge branch 'master' of github.com:erykpiast/angular-url-format

eerykpiast committed 11 years ago

README

The README file for this repository.

angular-url-format

AngularJS filter for formatting URLs.

Usage

Add angular-url-format as your app dependency.

  angular.module('myModule', [
    angular-url-format'
  ]);

In templates you can use

  <p>
    Domain: {{ url | url:'hostname' }}<br/>
    Preformatted: {{ urlPre }}
  </p>

In controllers (or directives, services, anywhere)

  angular.module('myModule').controller('exampleCtrl', function($scope, $filter) {
    var timeFilter = $filter('url');
    
    $scope.url = 'http://usabilitytools.com/features-benefits/visitor-recording/;
    $scope.urlPre = timeFilter($scope.url, 'hostname');
  });

The result should be the same in both cases:

  Domain: usabilitytools.com
  Preformatted: usabilitytools.com

Format options

Available formatting options are the same like properties of window.location object, plus some additional exposed by Node.js URL object:

  • href
  • protocol
  • host
  • hostname
  • port
  • pathname
  • search
  • hash
  • path
  • query

Lack of username and password attributes is caused by the method of parsing URL. Parser use HTMLAnchorElement API which doesn't expose those properties in every browser (ex. PhantomJS). Fortunatelly, other parts of URL are resolved correctly even if user and password were set. Ex. for URL https://user:password@host.com/, the hostname part will be always host.com and protocol https:.