# mdast-util-fix-relative-uris

> Resolve relative URIs in MDAST

Latest version **0.1.1** (published 2021-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install mdast-util-fix-relative-uris
pnpm add mdast-util-fix-relative-uris
yarn add mdast-util-fix-relative-uris
bun add mdast-util-fix-relative-uris
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-04-02 |
| First published | 2021-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Takuya Matsuyama |
| Maintainers | craftzdog |
| Keywords | remark, micromark, mdast, ast |

## Links

- npm: https://www.npmjs.com/package/mdast-util-fix-relative-uris
- Repository: https://github.com/inkdropapp/mdast-util-fix-relative-uris
- Homepage: https://github.com/inkdropapp/mdast-util-fix-relative-uris#readme
- Issues: https://github.com/inkdropapp/mdast-util-fix-relative-uris/issues
- npm.io page: https://npm.io/package/mdast-util-fix-relative-uris

## Dependencies (1)

- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^2.0.3

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2021-04-02
- 0.1.0 — 2021-03-31

## README

# mdast-util-fix-relative-uris

**[mdast][]** utility to fix relative URIs.

## Install

[npm][]:

```sh
npm install mdast-util-fix-relative-uris
```

## Use

Say we have the following markdown file, `example.md`:

```markdown
[link](about)
```

And our script, `example.js`, looks as follows:

```js
var fs = require("fs");
var fromMarkdown = require("mdast-util-from-markdown");
var fixRelativeURIs = require("mdast-util-fix-relative-uris");

var doc = fs.readFileSync("example.md");

var tree = fromMarkdown(doc);
var baseURL = "https://www.inkdrop.app/";
var fixedTree = fixRelativeURIs(tree, baseURL);

console.log(fixedTree);
```

Now, running `node example` yields (positional info removed for brevity):

```js
{
  type: 'root',
  children: [
    {
      type: 'paragraph',
      children: [
        {
          type: 'link',
          title: null,
          url: 'https://www.craftz.dog/about',
          children: [
            {
              type: 'text',
              value: 'link',
            }
          ],
        }
      ],
    }
  ],
}
```

## API

### `fixRelativeURIs(tree, baseURI)`

Fix relative URIs of links in the given [mdast][] tree.

#### Parameters

- `baseURI` (`string`) — The base URI

#### Returns

The given, modified, tree.

## License

[MIT][license] © [Takuya Matsuyama][author]

[mdast]: https://github.com/syntax-tree/mdast
[npm]: https://docs.npmjs.com/cli/install
[license]: LICENSE
[author]: https://www.craftz.dog/

---
_Source: https://npm.io/package/mdast-util-fix-relative-uris · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
