urn-parser - Module for URN parsing
Overview
URN-Parser is a module that provides functions for parsing URN (Uniform Resource Name) that is loosely
based upon the standard url
module within node
. Parsing is derived from the excellent parseUri
function by Steven Levithan, but stripped down for the urn
scheme.
Although the URN-parser is a good start, for a more complete and fully compliant implementation
I recommend you take a look at the URI Type for javascript module which
allows the urn
to be inspected as an uri
.
What's an URN?
The best place to start if you want to know more about URNs is (of course) the wikipedia article on Uniform Resource Name.
Installation
npm install urn-parser
Using the Module
The 'urn-parser' module is accessed in the standard way by calling require("urn-parser");
and once loaded
you have access to the following objects and functions.
urn-parser.Parser
Class The Parser
class is a wrapper object class that provides access to an object that can be
used to parse urn
instances.
This class has the following interface:
Parser(options)
Constructor Creates a new instance with the specified options
Parser.parse(urnStr, strictMode)
Method Parses an URN into components (optionally in strict mode)
Parser.complete(obj)
Method Creates a complete URN definition from its components
Parser.format(obj)
Method Formats an URN definition into a well-formed URN string
urn-parser.parse
Function The parse
function is a proxy to the Parser.parse(urnStr, strictMode)
method on a singleton Parser
instance that is created for the module.
urn-parser.complete
Function The complete
function is a proxy to the Parser.complete(obj)
method on a singleton Parser
instance that is created for the module.
urn-parser.format
Function The format
function is a proxy to the Parser.format(obj)
method on a singleton Parser
instance that is created for the module.
Contributors
License
MIT License
Acknowledgements
- Steven Levithan for the
parseUri
function that is the basis of this module
Author
Stuart Hudson