# node-url-get
**Repository Path**: mirrors_wikimedia/node-url-get
## Basic Information
- **Project Name**: node-url-get
- **Description**: Library functions to fetch and parse YAML or JSON content at local or remote URLs.
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-11-17
- **Last Updated**: 2026-06-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## url-get
This module contains library functions to fetch and parse YAML or JSON content
at local or remote URLs.
* [url-get](#module_url-get)
* [~objectFactory(data)](#module_url-get..objectFactory) ⇒ Object
* [~uriHasProtocol(uri)](#module_url-get..uriHasProtocol) ⇒ boolean
* [~fileExtension(filename)](#module_url-get..fileExtension) ⇒ string
* [~resolveUri(uri, baseUri, defaultFileExtension)](#module_url-get..resolveUri) ⇒ Promise.<Object>
* [~urlGet(url, options)](#module_url-get..urlGet) ⇒ Promise.<string>
* [~urlGetObject(url, options)](#module_url-get..urlGetObject) ⇒ Promise.<Object>
* [~urlGetFirstObject(urls, options)](#module_url-get..urlGetFirstObject) ⇒ Promise.<Object>
* [~uriGetFirstObject(uri, baseUris, defaultFileExtension, options)](#module_url-get..uriGetFirstObject) ⇒ Promise.<Object>
### url-get~objectFactory(data) ⇒ Object
Converts a utf-8 byte buffer or a YAML/JSON string into
an object and returns it.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type |
| --- | --- |
| data | string \| Buffer \| Object |
### url-get~uriHasProtocol(uri) ⇒ boolean
Returns true if the uri has protocol schema on the front, else false.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type |
| --- | --- |
| uri | string |
### url-get~fileExtension(filename) ⇒ string
Returns the file extension (or the last part after a final '.' in a file basename)
of a filename path. If no file extension is present, this returns an empty string.
If the final part of a file name after '.' is numeric, this is not a file
extension, and an empty string will be returned.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type |
| --- | --- |
| filename | string |
### url-get~resolveUri(uri, baseUri, defaultFileExtension) ⇒ Promise.<Object>
Takes a possibly relative uri, and augments it so that it is better suited for use in requests.
If the uri is already qualified (e.g. is starts with a protocol scheme), baseUri will
not be prepended.
If the uri already ends in a file extensions, defaultFileExtension will not be appended.
If the baseUri given does not have a protocol schema, it is assumed to be file://.
file:// paths will be resolved with path.resolve to be transformed into absolute file paths.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type | Description |
| --- | --- | --- |
| uri | string | uri to resolve with baseUri and defaultFileExtension |
| baseUri | string | If given, uris that don't start with a protocol scheme will be prepended with this. |
| defaultFileExtension | string | If given, uris that don't end with a file extension will be appended with this. |
### url-get~urlGet(url, options) ⇒ Promise.<string>
Given a string URL, returns a Promise of the contents at that
URL. Supports both file:// (via fs.readFile) and other http
based URLs with preq.get.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type | Description |
| --- | --- | --- |
| url | string | |
| options | Object | Options to pass to the function used to open the url. This will be different for local files vs remote (http) URIs, so make sure you pass options that make sense for that url. |
### url-get~urlGetObject(url, options) ⇒ Promise.<Object>
Given a URL, returns a Promise of the contents at that
converted into an Object. The content at URL
must either be a JSON or YAML string.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type | Description |
| --- | --- | --- |
| url | string | |
| options | Object | Options to pass to the function used to open the url. This will be different for local files vs remote (http) URIs, so make sure you pass options that make sense for that url. |
### url-get~urlGetFirstObject(urls, options) ⇒ Promise.<Object>
Given a list of URLs, returns a Promise of the first resolved
result of urlGetObject. If no URL resolves, this will return
the final rejection.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type | Description |
| --- | --- | --- |
| urls | Array.<string> | |
| options | Object | Options to pass to the function used to open the url. This will be different for local files vs remote (http) URIs, so make sure you pass options that make sense for that url. |
### url-get~uriGetFirstObject(uri, baseUris, defaultFileExtension, options) ⇒ Promise.<Object>
Combines resolveUri and urlGetObjectFirst to return the first
baseUri + uri combination that resolves to an object.
**Kind**: inner method of [url-get](#module_url-get)
| Param | Type | Description |
| --- | --- | --- |
| uri | string | uri to resolve with baseUri and defaultFileExtension |
| baseUris | Array.<string> | If given, uris that don't start with a protocol scheme will be prepended with these. |
| defaultFileExtension | string | If given, uris that don't end with a file extension will be appended with this. |
| options | Object | Options to pass to the function used to open the url. This will be different for local files vs remote (http) URIs, so make sure you pass options that make sense for that url. |