Comparing version 0.6.7 to 0.6.8
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.6.8](https://github.com/nuxt-contrib/ufo/compare/v0.6.7...v0.6.8) (2021-03-05) | ||
### Features | ||
* **hasProtocol:** optionally allow protocol relative url ([#16](https://github.com/nuxt-contrib/ufo/issues/16)) ([81a3f3e](https://github.com/nuxt-contrib/ufo/commit/81a3f3e9f203fb27869ea7d3d0e99f256d33e968)) | ||
### [0.6.7](https://github.com/nuxt-contrib/ufo/compare/v0.6.6...v0.6.7) (2021-02-22) | ||
@@ -7,0 +14,0 @@ |
@@ -117,3 +117,3 @@ /** | ||
declare function hasProtocol(inputStr: string): boolean; | ||
declare function hasProtocol(inputStr: string, acceptProtocolRelative?: boolean): boolean; | ||
declare function hasTrailingSlash(input?: string): boolean; | ||
@@ -120,0 +120,0 @@ declare function withoutTrailingSlash(input?: string): string; |
@@ -261,4 +261,4 @@ 'use strict'; | ||
function hasProtocol(inputStr) { | ||
return /^\w+:\/\//.test(inputStr); | ||
function hasProtocol(inputStr, acceptProtocolRelative = false) { | ||
return /^\w+:\/\/.+/.test(inputStr) || acceptProtocolRelative && /^\/\/[^/]+/.test(inputStr); | ||
} | ||
@@ -347,6 +347,6 @@ function hasTrailingSlash(input = "") { | ||
function parseURL(input = "") { | ||
if (!hasProtocol(input)) { | ||
if (!hasProtocol(input, true)) { | ||
return parsePath(input); | ||
} | ||
const [protocol, auth, hostAndPath] = (input.match(/([^:/]+:)\/\/([^/@]+@)?(.*)/) || []).splice(1); | ||
const [protocol = "", auth, hostAndPath] = (input.match(/([^:/]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1); | ||
const [host = "", path = ""] = (hostAndPath.match(/([^/]*)(.*)?/) || []).splice(1); | ||
@@ -353,0 +353,0 @@ const {pathname, search, hash} = parsePath(path); |
{ | ||
"name": "ufo", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "URL utils for humans", | ||
@@ -5,0 +5,0 @@ "repository": "nuxt-contrib/ufo", |
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
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
42975