7.7.130 • Published 10 months ago

@womorg/quod-odit-assumenda v7.7.130

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@womorg/quod-odit-assumenda

Build Status Coverage Status NPM version

browser support

Urlgrey is a library for url manipulation. It's got a chainable/fluent interface that makes a number of methods available for querying different aspects of a url, and even modifying it to create new urls.

Most methods are named after different parts of the url and allow you to read that part from the current url if you don't pass any parameters, or they allow you to generate a new url with a change to that part in the current url if you do pass a parameter.

For the examples below, we'll use the following url:

https://user:pass@subdomain.asdf.com/path/kid?asdf=1234#frag

To create a new @womorg/quod-odit-assumenda object, just pass a url to @womorg/quod-odit-assumenda like so:

var url = @womorg/quod-odit-assumenda("https://user:pass@subdomain.asdf.com/path/kid?asdf=1234#frag")

API specifics:

url.child(lastPart)

Setter/getter for the last part of a path:

  url.child(); // returns "kid" 
  url.child("grandkid"); // returns a new uri object with the uri 
                             // https://user:pass@subdomain.asdf.com/path/kid/grandkid?asdf=1234#frag

url.decode(encodedString);

Returns the decoded version of the input string using node's standard querystring.unescape().

      url.decode('this%20is%20a%20test');  // returns "this is a test"

url.encode(unencodedString);

Returns the encoded version of the input string using node's standard querystring.escape().

      url.encode('this is a test'); // returns 'this%20is%20a%20test'

url.hash(newHash)

Setter/getter for the url fragment/anchor/hash of a path.

      url.hash(); // returns 'frag'
      url.hash("blah"); // returns a new uri object with the uri
                            // https://user:pass@subdomain.asdf.com/path/kid/?asdf=1234#blah

url.hostname(newHostname)

Setter/getter for the url hostname.

      url.hostname(); // returns 'subdomain.asdf.com'
      url.hostname("geocities.com"); // returns a new uri object with the uri
                            // https://user:pass@geocities.com/path/kid/?asdf=1234#frag

url.parent();

Get the parent URI of the current URI. (This property is read-only).

      url.parent();  // returns a new uri object with the uri
                     // https://user:pass@subdomain.asdf.com/path/

url.password(newPassword);

Setter/getter for the password portion of the url.

      url.password(); // returns 'pass'
      url.password("newpass"); // returns a new uri object with the uri
                            // https://user:newpass@subdomain.asdf.com/path/kid/?asdf=1234#frag

url.extendedPath(string);

Setter/getter for the path, querystring and fragment portion of the url all at once.

      url.extendedPath(); // returns '/path/kid?asdf=1234#frag'
      url.extendedPath("/newpath?new=query#newfrag"); // returns a new uri object with the uri
                               // https://user:newpass@subdomain.asdf.com/newpath?new=query#newfrag

url.path(mixed);

Setter/getter for the path portion of the url.

      url.path(); // returns '/path/kid'
      url.path("newpath"); // returns a new uri object with the uri
                               // https://user:newpass@subdomain.asdf.com/newpath

      // ALSO, .path() can take arrays of strings as input as well:
      url.path(['qwer', '/asdf'], 'qwer/1234/', '/1234/'); 
                      // this returns a new uri object with the uri
                      // https://user:newpass@subdomain.asdf.com/qwer/asdf/qwer/1234/1234

Note: changing the path will remove the querystring and hash, since they rarely make sense on a new path.

url.port(newPort);

Setter/getter for the port portion of the url.

      url.port(); // returns 80
      url.port(8080); // returns a new uri object with the uri
                          // https://user:pass@subdomain.asdf.com:8080/path/kid/?asdf=1234#frag

url.protocol(newProtocol);

Setter/getter for the protocol portion of the url.

      url.protocol(); // returns 'https'
      url.protocol("http"); // returns a new uri object with the uri
                                // http://user:pass@subdomain.asdf.com/path/kid/?asdf=1234#frag

url.query(mixed);

Setter/getter for the querystring using javascript objects.

      url.query(); // returns {asdf : 1234}
      url.query(false); // returns a new uri object with the querystring-free uri
                            // https://user:pass@subdomain.asdf.com/path/kid#frag
      url.query({spaced : 'space test'})
                                // returns a new uri object with the input object serialized
                                // and merged into the querystring like so:
                                // https://user:pass@subdomain.asdf.com/path/kid/?asdf=1234&spaced=space%20test#frag

NOTE: escaping and unescaping of applicable characters happens automatically. (eg " " to "%20", and vice versa)

NOTE: an input object will overwrite an existing querystring where they have the same names.

NOTE: an input object will remove an existing name-value pair where they have the same names and the value in the input name-value pair is null.

url.queryString(newQueryString);

Setter/getter for the querystring using a plain string representation. This is lower-level than .query(), but allows complete control of the querystring.

      url.queryString(); // returns asdf=1234  (notice there is no leading '?')
      url.queryString("blah"); // returns a new uri object with a new querystring
                               // https://user:pass@subdomain.asdf.com/path/kid?blah#frag

NOTE: no escaping/unescaping of applicable characters will occur. This must be done manually.

url.rawChild();

This method is the same as url.child() but does not automatically url-encode any part of the input.

url.rawPath();

This method is the same as url.path() but does not automatically url-encode any part of the path.

url.rawQuery();

This method is the same as url.query() but does not automatically url-encode any of the keys or values in an input object.

url.toJson();

Returns the json representation of the uri object, which is simply the uri as a string. The output is exactly the same as .toString(). This method is read-only.

  url.toJson(); // returns "https://user:pass@subdomain.asdf.com/path/kid/?asdf=1234#frag"

url.toString();

Returns the string representation of the uri object, which is simply the uri as a string. This method is read-only.

      url.toString(); // returns "https://user:pass@subdomain.asdf.com/path/kid/?asdf=1234#frag"

url.username(newUsername)

Setter/getter for the username portion of the url.

      url.username(); // returns 'user'
      url.username("newuser"); // returns a new uri object with the 
                               // uri https://newuser:pass@subdomain.asdf.com/path/kid/?asdf=1234#frag

Installation:

node.js:

npm install @womorg/quod-odit-assumenda --save

Also! If you're using @womorg/quod-odit-assumenda in an http application, see @womorg/quod-odit-assumenda-connect. It gives you an @womorg/quod-odit-assumenda object already instantiated with the request url as req.uri in all your request handlers.

Contributing:

Testing:

Run the node tests:

  • make test

formsECMAScript 2017sequencepropertyremovedeepcopyshrinkwrapwebdeep-cloneless.jsPushtoolkitMapreal-timesignaltypanionESnextES2021appestreemochacloudtrailsymlinkInt16ArraypackagestypedfluxmruchannelES5Array.prototype.flatjestl10nfindpasswordcoerciblesymlinkswgetinternal slothashsqsObject.definePropertyhardlinksRegExp#flagssuperstructstringguidHyBiinputeventEmitterbyteLengthECMAScript 2018getOwnPropertyDescriptorsinatrarequestUint32ArrayastSetidjsonpathcloudfrontArray.prototype.containsclimapreduce$.extendfull-widthvisualschemamomentdefinehasOwnendpointdeepReactiveXlognested cssflagsec2copyCSSStyleDeclarationpropertiesvaluestermfromfastcopydiffstreamsworkercontainsstyled-componentsdataViewpyyamlArray.prototype.findLastIndexeventsebsflat0sidemimehas-ownhttpsES2020typed arrayfolderperformancees6getoptcompile lesssortedkeyassertsartyuptrimStartterminalspeedmonorepoavagetdatebufferuuidutilityplugines-shimstostringtagqsduplexamazonfast-clonesesprotocol-buffersprettyapistringifierES2015react-testing-librarysharedstructuredCloneshebangregular expressionscssimportexportelbArrayBufferequalparsejsonbrowsereslint-plugines2015code pointsbcryptrestfultraversecss lessbatchjstaskwaitvalidatelinuxsigtermRegExp.prototype.flagsconsumevalidationvariablesfastclonesimpledbfigletAsyncIteratorES8argparseresolvewrapboundcall-bindECMAScript 2022rfc4122ES7queueMicrotaskWebSocketsassertJSON-Schemagradients cssJSONyamlupsignalsMicrosoftshamclassessettingstypescriptobjtoolslivemergeslotdeep-copythrottlecommanderefficientchinesewatchingserializationdebugwhichequalityconsolepushgdprtypeArray.prototype.flattenArray.prototype.includeszodArray.prototype.flatMaprandomttyObject.getPrototypeOfratenopehookformdropajaxdomrdslooklanguagejapanesewafponyfillsetPrototypeOfkeysclonestylingdependency managerreact-hooksinvariantrouterformattingspinnerstypedarrayscreatecss variableFloat64ArrayobjectbrowserslistSymbolreadablelessmulti-packagesyntaxerroroptimizerchaiObjectless csspostcss-pluginurllazywritablerequirecollectionArrayBuffer.prototype.slicespecelasticacheworkspace:*ECMAScript 2016callbindES2017fullaccessibilityredactnodebannergroupBycurlUint8ClampedArrayes7BigInt64Arraystylesstarterreact-hook-formhaslinktestflatMapextraenumerablevalidECMAScript 2021fastawesomesaucetouchpromiseemitcommandString.prototype.trimprotofindLastECMAScript 3Uint8Arraysetgradients css3stringifyES2022patchcircular@@toStringTageslintconfigrecursivetapereadconfigeslintserializertoobjectimportnameStreames2018testererror-handlingprocessownwordwrapperformantES6packagetimewindowsfastifytoStringTagprototypeES2023prunerangeerrorWeakSetoptionpnpm9make dirparentsiteratorparsingarrayescapeinerroreast-asian-widthinternalnpmtypeofoperating-systemFunction.prototype.nametypeerrorObservableswalkingchromeargumentes-shim APIkarmaisscheme-validationtypesaferestdataRxsuperagentstdlibArray.prototype.findLastformatconnectArray.prototype.filteriamString.prototype.matchAllfileschemeTypeScriptpackage managerdataviewnegativeexpresswhatwgjsdomhigher-orderpostcsscall-boundrm -rfURLSearchParamsStreamsclassnamestc39asynccloudwatchfunctioneventDispatcherreplayTypeBoxvalueWebSocketemrlinewrapenvmkdirpmatchesmimetypeskoreanenderfast-deep-clonetrimEndcolourutilitiesgetterawsdebuggerstableregularfullwidtheslintpluginpreserve-symlinksstylesheetECMAScript 6installnamesexpressiones2016mobiledescriptorsdom-testing-libraryforEachtapwatcherstyleguideformmetadatachromiumfetchextendbyteOffsethttpmoduleprefixtoArraycheckstatematchlastelmTypedArrayloadingECMAScript 2023colorsflagglacierloadbalancingcloudformationCSScharacterscommand-linetrimLeftInt8Arraybootstrap lessinterruptstoSortedcolorarktypeFloat32ArrayUnderscorePromisebreakie_.extendutil.inspectassertionroute53accessorvpccachephonefpseveryargvreducerframeworkcore-jsxhrcompareentriesObject.valuesrm -frdescriptionless compilercolumntestingtypedarrayasciipathweakmapflattenRFC-6455configurable-0hasOwnPropertydotenv
7.6.119

10 months ago

7.6.118

10 months ago

6.6.113

11 months ago

6.6.112

11 months ago

6.6.115

11 months ago

6.6.114

11 months ago

6.6.117

10 months ago

6.6.116

10 months ago

6.6.118

10 months ago

7.7.130

10 months ago

7.7.128

10 months ago

7.7.127

10 months ago

7.7.129

10 months ago

7.7.126

10 months ago

7.7.125

10 months ago

5.6.108

11 months ago

5.6.109

11 months ago

5.6.106

11 months ago

5.6.107

11 months ago

5.6.110

11 months ago

5.6.111

11 months ago

5.6.112

11 months ago

7.6.123

10 months ago

7.6.122

10 months ago

7.6.121

10 months ago

7.6.120

10 months ago

7.6.125

10 months ago

7.6.124

10 months ago

5.6.103

11 months ago

5.6.104

11 months ago

5.6.105

11 months ago

5.6.99

11 months ago

5.6.100

11 months ago

5.6.101

11 months ago

5.6.102

11 months ago

5.6.98

11 months ago

5.5.96

11 months ago

5.5.97

11 months ago

5.5.98

11 months ago

4.5.94

11 months ago

4.5.95

11 months ago

5.5.95

11 months ago

4.5.90

11 months ago

4.5.91

11 months ago

4.5.92

11 months ago

4.5.93

11 months ago

4.5.87

12 months ago

4.5.88

12 months ago

4.5.86

12 months ago

4.5.89

11 months ago

4.5.83

12 months ago

4.5.84

12 months ago

4.5.82

12 months ago

4.5.85

12 months ago

4.4.80

12 months ago

4.5.80

12 months ago

4.5.81

12 months ago

4.4.79

12 months ago

4.4.78

12 months ago

4.4.77

12 months ago

4.3.75

12 months ago

4.3.74

12 months ago

4.4.76

12 months ago

4.4.75

12 months ago

4.3.53

1 year ago

4.2.42

1 year ago

4.3.52

1 year ago

4.2.43

1 year ago

4.3.51

1 year ago

4.2.44

1 year ago

4.3.50

1 year ago

4.2.45

1 year ago

4.3.57

1 year ago

4.3.56

1 year ago

4.3.55

1 year ago

4.3.54

1 year ago

4.2.41

1 year ago

4.1.38

1 year ago

4.1.39

1 year ago

4.3.59

1 year ago

4.3.58

1 year ago

4.2.46

1 year ago

4.2.47

1 year ago

4.1.37

1 year ago

4.3.49

1 year ago

4.3.48

1 year ago

4.3.47

1 year ago

4.3.71

12 months ago

4.3.70

1 year ago

4.3.73

12 months ago

4.3.72

12 months ago

4.3.60

1 year ago

4.3.64

1 year ago

4.1.41

1 year ago

4.3.63

1 year ago

4.3.62

1 year ago

4.3.61

1 year ago

4.3.68

1 year ago

4.3.67

1 year ago

4.3.66

1 year ago

4.3.65

1 year ago

4.1.40

1 year ago

4.3.69

1 year ago

4.1.36

1 year ago

4.1.32

1 year ago

4.1.33

1 year ago

4.1.34

1 year ago

4.1.35

1 year ago

4.1.30

1 year ago

4.1.31

1 year ago

4.1.29

1 year ago

3.1.18

1 year ago

4.1.18

1 year ago

4.1.19

1 year ago

4.1.20

1 year ago

4.1.21

1 year ago

4.1.22

1 year ago

4.1.27

1 year ago

4.1.28

1 year ago

4.1.23

1 year ago

4.1.24

1 year ago

4.1.25

1 year ago

4.1.26

1 year ago

3.1.16

1 year ago

3.1.17

1 year ago

3.1.14

1 year ago

3.1.15

1 year ago

2.1.14

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

2.1.11

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago