1.0.7 • Published 10 years ago

xos.url v1.0.7

Weekly downloads
17
License
Free for non-comm...
Repository
github
Last release
10 years ago

XOS URL Parser

Introduction

Parses a URL and the contained query string into an object

  • source
  • protocol
  • authority
  • credentials
  • username
  • password
  • host
  • port
  • relative
  • path
  • directory
  • file
  • query_string
  • query (object)
  • anchor

Installation

npm install xos.url

Usage

Simply require and instantiate a URL

URL=require('../../xos.url')
url='https://user:password@sub.domain.com:1337/path/to/folder/file.extension?para=value&para2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue#anchor&anchorpart'
u=new URL(url)
console.log(u.parsed)

output

Output of the above snippet is:

  { source: 'https://user:password@sub.domain.com:1337/path/to/folder/file.extension?para=value&para2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue#anchor&anchorpart',
  protocol: 'https',
  authority: 'user:password@sub.domain.com:1337',
  credentials: 'user:password',
  username: 'user',
  password: 'password',
  host: 'sub.domain.com',
  port: '1337',
  relative: '/path/to/folder/file.extension?para=value&para2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue#anchor&anchorpart',
  path: '/path/to/folder/file.extension',
  directory: '/path/to/folder/',
  file: 'file.extension',
  query_string: 'para=value&para2=value2&user[name]=myusername&user[password]=mypassword&another[nested][object][key]=nestedobjectvalue',
  anchor: 'anchor&anchorpart',
  query: 
  { para: 'value',
   para2: 'value2',
   user: { name: 'myusername', password: 'mypassword' },
   another: { nested: [Object] } } }
1.0.7

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago