Skip to content

Commit

Permalink
Document currentUrl parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jun 24, 2017
1 parent 7e1ffc4 commit 90a32f3
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@ $ npm install --save shorten-repo-url
```js
const shortenRepoUrl = require('shorten-repo-url');

const HTML = shortenRepoUrl('https://github.com/nodejs/node/tree/v0.12/doc');
//=> 'nodejs/node@<code>v0.12</code>'

const HTML = shortenRepoUrl(
'https://github.com/nodejs/node/tree/v0.12/doc',
'https://github.com/nodejs/node' // same repo
);
//=> '<code>v0.12</code>' // repo-less URL

const HTML = shortenRepoUrl(
'https://github.com/nodejs/node/tree/v0.12/doc',
'https://github.com' // not the same repo
);
//=> 'nodejs/node@<code>v0.12</code>' // URL with repo

```


## API

### shortenRepoUrl(url)
### shortenRepoUrl(url, currentUrl)

Returns the shortened URL in HTML as a `string` like `nodejs/node@<code>v0.12</code>`.

Expand All @@ -36,6 +47,12 @@ Type: `string`

The GitHub URL to shorten.

#### currentUrl

Type: `string`, like `location.href`

The URL of the current page, to build relative URLs like `<code>v0.12</code>` instead of the longer `nodejs/node@<code>v0.12</code>`

### shortenRepoUrl.applyToLink(link)

Type: `Element`
Expand Down

0 comments on commit 90a32f3

Please sign in to comment.