demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/parseurl-1.3.3/index.js

Path
demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/parseurl-1.3.3/index.js
Status
scanned
Type
file
Name
index.js
Extension
.js
Programming language
JavaScript
Mime type
text/plain
File type
ASCII text
Tag

      
    
Rootfs path

      
    
Size
2809 (2.7 KB)
MD5
3750351b6b1aa7f3e65d5499ea45006e
SHA1
7f8870a8a8d53bda04d1c61037a348b5ae2f7de8
SHA256
811223d4a19492ccc642384dc84f0af4ad935557dfe8f63750d7ffd673e40f17
SHA512

      
    
SHA1_git
ece722327959f3bd9721488a035947387f1c1db1
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
index.js | 2.7 KB |

/*! * parseurl * Copyright(c) 2014 Jonathan Ong * Copyright(c) 2014-2017 Douglas Christopher Wilson * MIT Licensed */ 'use strict' /** * Module dependencies. * @private */ var url = require('url') var parse = url.parse var Url = url.Url /** * Module exports. * @public */ module.exports = parseurl module.exports.original = originalurl /** * Parse the `req` url with memoization. * * @param {ServerRequest} req * @return {Object} * @public */ function parseurl (req) { var url = req.url if (url === undefined) { // URL is undefined return undefined } var parsed = req._parsedUrl if (fresh(url, parsed)) { // Return cached URL parse return parsed } // Parse the URL parsed = fastparse(url) parsed._raw = url return (req._parsedUrl = parsed) }; /** * Parse the `req` original url with fallback and memoization. * * @param {ServerRequest} req * @return {Object} * @public */ function originalurl (req) { var url = req.originalUrl if (typeof url !== 'string') { // Fallback return parseurl(req) } var parsed = req._parsedOriginalUrl if (fresh(url, parsed)) { // Return cached URL parse return parsed } // Parse the URL parsed = fastparse(url) parsed._raw = url return (req._parsedOriginalUrl = parsed) }; /** * Parse the `str` url with fast-path short-cut. * * @param {string} str * @return {Object} * @private */ function fastparse (str) { if (typeof str !== 'string' || str.charCodeAt(0) !== 0x2f /* / */) { return parse(str) } var pathname = str var query = null var search = null // This takes the regexp from https://github.com/joyent/node/pull/7878 // Which is /^(\/[^?#\s]*)(\?[^#\s]*)?$/ // And unrolls it into a for loop for (var i = 1; i < str.length; i++) { switch (str.charCodeAt(i)) { case 0x3f: /* ? */ if (search === null) { pathname = str.substring(0, i) query = str.substring(i + 1) search = str.substring(i) } break case 0x09: /* */ case 0x0a: /* */ case 0x0c: /* \f */ case 0x0d: /* */ case 0x20: /* */ case 0x23: /* # */ case 0xa0: case 0xfeff: return parse(str) } } var url = Url !== undefined ? new Url() : {} url.path = str url.href = str url.pathname = pathname if (search !== null) { url.query = query url.search = search } return url } /** * Determine if parsed is still fresh for url. * * @param {string} url * @param {object} parsedUrl * @return {boolean} * @private */ function fresh (url, parsedUrl) { return typeof parsedUrl === 'object' && parsedUrl !== null && (Url === undefined || parsedUrl instanceof Url) && parsedUrl._raw === url }
Detected license expression
mit
Detected license expression (SPDX)
MIT
Percentage of license text
0.62
Copyrights
- end_line: 3
  copyright: Copyright (c) 2014 Jonathan Ong
  start_line: 3
- end_line: 4
  copyright: Copyright (c) 2014-2017 Douglas Christopher Wilson
  start_line: 4
Holders
- holder: Jonathan Ong
  end_line: 3
  start_line: 3
- holder: Douglas Christopher Wilson
  end_line: 4
  start_line: 4
Authors

      
    
License detections License expression License expression SPDX
mit-4e7803e6-e54b-c9ca-bcd2-bee9755c0dd7 mit MIT
URL Start line End line
https://github.com/joyent/node/pull/7878 104 104
Package URL License Primary language
pkg:npm/acme-demo-app@1.0.0 JavaScript
pkg:npm/parseurl@1.3.3 mit JavaScript