Comparing version 8.1.0 to 9.0.0
@@ -1,18 +0,21 @@ | ||
declare interface ParsedUrl { | ||
protocols: string[]; | ||
protocol: string; | ||
port?: string; | ||
resource: string; | ||
user: string; | ||
pathname: string; | ||
hash: string; | ||
search: string; | ||
href: string; | ||
query: { | ||
[key: string]: any; | ||
} | ||
import parsePath = require("parse-path"); | ||
import normalizeUrl = require("normalize-url"); | ||
declare namespace parseUrl { | ||
const MAX_INPUT_LENGTH: 2048; | ||
type NormalizeOptions = normalizeUrl.Options; | ||
type ParsedUrl = parsePath.ParsedPath; | ||
interface ParsingError extends Error { | ||
readonly subject_url: string; | ||
} | ||
} | ||
declare function parseUrl(url: string, normalize?: boolean | Object): ParsedUrl; | ||
declare function parseUrl( | ||
url: string, | ||
normalize?: boolean | parseUrl.NormalizeOptions | ||
): parseUrl.ParsedUrl; | ||
export = parseUrl | ||
export = parseUrl; |
{ | ||
"name": "parse-url", | ||
"version": "8.1.0", | ||
"version": "9.0.0", | ||
"description": "An advanced url parser supporting git urls too.", | ||
@@ -9,5 +9,10 @@ "main": "./dist/index.js", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs" | ||
"require": { | ||
"types": "./index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"import": { | ||
"types": "./index.d.mts", | ||
"default": "./dist/index.mjs" | ||
} | ||
}, | ||
@@ -19,3 +24,3 @@ "directories": { | ||
"scripts": { | ||
"test": "node test/index.mjs", | ||
"test": "node test/index.mjs && tsd", | ||
"build": "pkgroll" | ||
@@ -43,5 +48,7 @@ }, | ||
"pkgroll": "^1.4.0", | ||
"tester": "^1.3.1" | ||
"tester": "^1.3.1", | ||
"tsd": "^0.24.1" | ||
}, | ||
"dependencies": { | ||
"@types/parse-path": "^7.0.0", | ||
"parse-path": "^7.0.0" | ||
@@ -65,2 +72,5 @@ }, | ||
], | ||
"engines": { | ||
"node": ">=14.13.0" | ||
}, | ||
"blah": { | ||
@@ -70,3 +80,6 @@ "description": [ | ||
] | ||
}, | ||
"tsd": { | ||
"directory": "test" | ||
} | ||
} |
181
README.md
@@ -52,11 +52,4 @@ <!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. --> | ||
## :cloud: Installation | ||
```sh | ||
# Using npm | ||
npm install --save parse-url | ||
# Using yarn | ||
yarn add parse-url | ||
``` | ||
@@ -70,7 +63,2 @@ | ||
## :clipboard: Example | ||
@@ -170,49 +158,13 @@ | ||
## :memo: Documentation | ||
### `interopDefaultLegacy()` | ||
#__PURE__ | ||
### `parseUrl(url, normalize)` | ||
Parses the input url. | ||
**Note**: This *throws* if invalid urls are provided. | ||
#### Params | ||
- **String** `url`: The input url. | ||
- **Boolean|Object** `normalize`: Whether to normalize the url or not. Default is `false`. If `true`, the url will | ||
be normalized. If an object, it will be the | ||
options object sent to [`normalize-url`](https://github.com/sindresorhus/normalize-url). | ||
For SSH urls, normalize won't work. | ||
#### Return | ||
- **Object** An object containing the following fields: | ||
- `protocols` (Array): An array with the url protocols (usually it has one element). | ||
- `protocol` (String): The first protocol, `"ssh"` (if the url is a ssh url) or `"file"`. | ||
- `port` (null|Number): The domain port. | ||
- `resource` (String): The url domain (including subdomains). | ||
- `user` (String): The authentication user (usually for ssh urls). | ||
- `pathname` (String): The url pathname. | ||
- `hash` (String): The url hash. | ||
- `search` (String): The url querystring value. | ||
- `href` (String): The input url. | ||
- `query` (Object): The url querystring, parsed as object. | ||
- `parse_failed` (Boolean): Whether the parsing failed or not. | ||
## :yum: How to contribute | ||
@@ -255,132 +207,3 @@ Have an idea? Found a bug? See [how to contribute][contributing]. | ||
## :dizzy: Where is this library used? | ||
If you are using this library in one of your projects, add it in this list. :sparkles: | ||
- `git-up` | ||
- `@semantic-release/gitlab` | ||
- `lien` | ||
- `stun` | ||
- `@open-wa/wa-automate` | ||
- `kakapo` | ||
- `parse-db-uri` | ||
- `fuge-runner` | ||
- `url-local` | ||
- `build-plugin-ssr` | ||
- `rucksack` | ||
- `egg-muc-custom-loader` | ||
- `hologit` | ||
- `@enkeledi/react-native-week-month-date-picker` | ||
- `normalize-ssh` | ||
- `robots-agent` | ||
- `warp-api` | ||
- `normalize-id` | ||
- `xl-git-up` | ||
- `warp-server` | ||
- `@hemith/react-native-tnk` | ||
- `@kriblet/wa-automate` | ||
- `@notnuzzel/crawl` | ||
- `gitlab-backup-util-harduino` | ||
- `miguelcostero-ng2-toasty` | ||
- `native-kakao-login` | ||
- `npm_one_1_2_3` | ||
- `react-native-biometric-authenticate` | ||
- `react-native-arunmeena1987` | ||
- `react-native-contact-list` | ||
- `react-native-payu-payment-testing` | ||
- `react-native-is7` | ||
- `react-native-my-first-try-arun-ramya` | ||
- `react-native-kakao-maps` | ||
- `react-native-ytximkit` | ||
- `rn-adyen-dropin` | ||
- `begg` | ||
- `@positionex/position-sdk` | ||
- `@corelmax/react-native-my2c2p-sdk` | ||
- `@felipesimmi/react-native-datalogic-module` | ||
- `@hawkingnetwork/react-native-tab-view` | ||
- `@jprustv/sulla-hotfix` | ||
- `@mergulhao/wa-automate` | ||
- `cli-live-tutorial` | ||
- `drowl-base-theme-iconset` | ||
- `native-apple-login` | ||
- `react-native-cplus` | ||
- `npm_qwerty` | ||
- `vrt-cli` | ||
- `vue-cli-plugin-ice-builder` | ||
- `react-native-arunjeyam1987` | ||
- `soajs.repositories` | ||
- `ssh-host-manager` | ||
- `native-zip` | ||
- `graphmilker` | ||
- `react-native-bubble-chart` | ||
- `verify-aws-sns-signature` | ||
- `@dataparty/api` | ||
- `react-native-flyy` | ||
- `@react-18-pdf/root` | ||
- `@apardellass/react-native-audio-stream` | ||
- `@geeky-apo/react-native-advanced-clipboard` | ||
- `@hsui/plugin-wss` | ||
- `blitzzz` | ||
- `candlelabssdk` | ||
- `@roshub/api` | ||
- `@saad27/react-native-bottom-tab-tour` | ||
- `generator-bootstrap-boilerplate-template` | ||
- `npm_one_12_34_1_` | ||
- `npm_one_2_2` | ||
- `payutesting` | ||
- `react-native-responsive-size` | ||
- `vue-cli-plugin-ut-builder` | ||
- `xbuilder-forms` | ||
- `deploy-versioning` | ||
- `eval-spider` | ||
- `homebridge-pushcutter` | ||
- `@con-test/react-native-concent-common` | ||
- `tumblr-text` | ||
- `react-native-shekhar-bridge-test` | ||
- `loast` | ||
- `react-feedback-sdk` | ||
- `@oiti/documentoscopy-react-native` | ||
- `@snyk/sweater-comb` | ||
- `@angga30prabu/wa-modified` | ||
- `@hstech/utils` | ||
- `birken-react-native-community-image-editor` | ||
- `get-tarball-cli` | ||
- `luojia-cli-dev` | ||
- `reac-native-arun-ramya-test` | ||
- `react-native-plugpag-wrapper` | ||
- `react-native-pulsator-native` | ||
- `react-native-arun-ramya-test` | ||
- `react-native-arunramya151` | ||
- `react-native-transtracker-library` | ||
- `workpad` | ||
- `delta-screen` | ||
- `microbe.js` | ||
- `ndla-source-map-resolver` | ||
- `@jfilipe-sparta/react-native-module_2` | ||
- `cogoportutils` | ||
- `@lakutata-module/service` | ||
- `@buganto/client` | ||
- `@mockswitch/cli` | ||
- `angularvezba` | ||
- `api-reach-react-native-fix` | ||
- `react-native-syan-photo-picker` | ||
- `@wecraftapps/react-native-use-keyboard` | ||
- `hui-plugin-wss` | ||
- `l2forlerna` | ||
- `native-google-login` | ||
- `raact-native-arunramya151` | ||
- `react-native-modal-progress-bar` | ||
- `react-native-test-module-hhh` | ||
- `react-native-jsi-device-info` | ||
- `react-native-badge-control` | ||
- `wander-cli` | ||
- `heroku-wp-environment-sync` | ||
- `hubot-will-it-connect` | ||
- `normalize-ssh-url` | ||
- `ba-js-cookie-banner` | ||
- `ts-scraper` | ||
- `electron-info` | ||
- `rn-tm-notify` | ||
- `native-date-picker-module` | ||
- `@ndla/source-map-resolver` | ||
- `@jimengio/mocked-proxy` | ||
@@ -393,6 +216,2 @@ | ||
## :scroll: License | ||
@@ -399,0 +218,0 @@ |
@@ -1,5 +0,19 @@ | ||
// Dependencies | ||
import parsePath from "parse-path"; | ||
import normalizeUrl from "normalize-url"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; // Dependencies | ||
var _normalizeUrl = require("normalize-url"); | ||
var _normalizeUrl2 = _interopRequireDefault(_normalizeUrl); | ||
var _parsePath = require("parse-path"); | ||
var _parsePath2 = _interopRequireDefault(_parsePath); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -27,2 +41,3 @@ * parseUrl | ||
* - `resource` (String): The url domain (including subdomains). | ||
* - `host` (String): The fully qualified domain name of a network host, or its IP address. | ||
* - `user` (String): The authentication user (usually for ssh urls). | ||
@@ -36,46 +51,53 @@ * - `pathname` (String): The url pathname. | ||
*/ | ||
const parseUrl = (url, normalize = false) => { | ||
var parseUrl = function parseUrl(url) { | ||
var normalize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
// Constants | ||
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/]+?(?:\.git|\/)?)$/ | ||
/** | ||
* ([a-z_][a-z0-9_-]{0,31}) Try to match the user | ||
* ([\w\.\-@]+) Match the host/resource | ||
* (([\~,\.\w,\-,\_,\/,\s]|%[0-9A-Fa-f]{2})+?(?:\.git|\/)?) Match the path, allowing spaces/white | ||
*/ | ||
var GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:](([\~,\.\w,\-,\_,\/,\s]|%[0-9A-Fa-f]{2})+?(?:\.git|\/)?)$/; | ||
const throwErr = msg => { | ||
const err = new Error(msg) | ||
err.subject_url = url | ||
throw err | ||
} | ||
var throwErr = function throwErr(msg) { | ||
var err = new Error(msg); | ||
err.subject_url = url; | ||
throw err; | ||
}; | ||
if (typeof url !== "string" || !url.trim()) { | ||
throwErr("Invalid url.") | ||
throwErr("Invalid url."); | ||
} | ||
if (url.length > parseUrl.MAX_INPUT_LENGTH) { | ||
throwErr("Input exceeds maximum length. If needed, change the value of parseUrl.MAX_INPUT_LENGTH.") | ||
throwErr("Input exceeds maximum length. If needed, change the value of parseUrl.MAX_INPUT_LENGTH."); | ||
} | ||
if (normalize) { | ||
if (typeof normalize !== "object") { | ||
if ((typeof normalize === "undefined" ? "undefined" : _typeof(normalize)) !== "object") { | ||
normalize = { | ||
stripHash: false | ||
} | ||
}; | ||
} | ||
url = normalizeUrl(url, normalize) | ||
url = (0, _normalizeUrl2.default)(url, normalize); | ||
} | ||
const parsed = parsePath(url) | ||
var parsed = (0, _parsePath2.default)(url); | ||
// Potential git-ssh urls | ||
if (parsed.parse_failed) { | ||
const matched = parsed.href.match(GIT_RE) | ||
var matched = parsed.href.match(GIT_RE); | ||
if (matched) { | ||
parsed.protocols = ["ssh"] | ||
parsed.protocol = "ssh" | ||
parsed.resource = matched[2] | ||
parsed.host = matched[2] | ||
parsed.user = matched[1] | ||
parsed.pathname = `/${matched[3]}` | ||
parsed.parse_failed = false | ||
parsed.protocols = ["ssh"]; | ||
parsed.protocol = "ssh"; | ||
parsed.resource = matched[2]; | ||
parsed.host = matched[2]; | ||
parsed.user = matched[1]; | ||
parsed.pathname = "/" + matched[3]; | ||
parsed.parse_failed = false; | ||
} else { | ||
throwErr("URL parsing failed.") | ||
throwErr("URL parsing failed."); | ||
} | ||
@@ -85,6 +107,6 @@ } | ||
return parsed; | ||
} | ||
}; | ||
parseUrl.MAX_INPUT_LENGTH = 2048 | ||
parseUrl.MAX_INPUT_LENGTH = 2048; | ||
export default parseUrl; | ||
exports.default = parseUrl; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12398
2
4
5
103
232
+ Added@types/parse-path@^7.0.0
+ Added@types/parse-path@7.0.3(transitive)