Comparing version 0.19.0 to 0.19.1
@@ -10,7 +10,13 @@ "use strict"; | ||
const URL = require("./URL"); | ||
const phonyBase = "https://urlpath.fp-ts-std.samhh.com"; | ||
const isURLPath = (u) => URL.isURL(u) && u.origin === phonyBase; | ||
const phonyBase = new globalThis.URL("https://urlpath.fp-ts-std.samhh.com"); | ||
const ensureBase = x => (0, function_1.pipe)(phonyBase, URL.clone, b => { | ||
b.pathname = x.pathname; | ||
b.search = x.searchParams.toString(); | ||
b.hash = x.hash; | ||
return b; | ||
}); | ||
const isURLPath = (u) => URL.isURL(u) && u.origin === phonyBase.origin; | ||
exports.isURLPath = isURLPath; | ||
exports.clone = (0, Newtype_1.over)(URL.clone); | ||
const fromURL = (x) => (0, function_1.pipe)(new globalThis.URL(x.href, phonyBase), (Newtype_1.pack)); | ||
const fromURL = (x) => (0, function_1.pipe)(new globalThis.URL(x.href, phonyBase), ensureBase, (Newtype_1.pack)); | ||
exports.fromURL = fromURL; | ||
@@ -21,12 +27,7 @@ const toURL = (f) => (baseUrl) => (x) => E.tryCatch(() => new globalThis.URL((0, exports.toString)(x), baseUrl), e => f(e)); | ||
exports.toURLO = toURLO; | ||
const fromString = (f) => (x) => (0, function_1.pipe)(E.tryCatch(() => { | ||
const y = new globalThis.URL(x, phonyBase); | ||
if (y.origin !== phonyBase) | ||
throw new TypeError("Failed to retain phony base URL"); | ||
return y; | ||
}, e => f(e)), E.map((Newtype_1.pack))); | ||
const fromString = (f) => (x) => (0, function_1.pipe)(E.tryCatch(() => ensureBase(new globalThis.URL(x, phonyBase)), e => f(e)), E.map((Newtype_1.pack))); | ||
exports.fromString = fromString; | ||
exports.fromStringO = (0, function_1.flow)((0, exports.fromString)(function_1.identity), O.fromEither); | ||
const fromPathname = (x) => { | ||
const y = new globalThis.URL("", phonyBase); | ||
const y = URL.clone(phonyBase); | ||
y.pathname = x; | ||
@@ -33,0 +34,0 @@ return (0, Newtype_1.pack)(y); |
@@ -7,17 +7,18 @@ import * as E from "fp-ts/Either"; | ||
import * as URL from "./URL"; | ||
const phonyBase = "https://urlpath.fp-ts-std.samhh.com"; | ||
export const isURLPath = (u) => URL.isURL(u) && u.origin === phonyBase; | ||
const phonyBase = new globalThis.URL("https://urlpath.fp-ts-std.samhh.com"); | ||
const ensureBase = x => pipe(phonyBase, URL.clone, b => { | ||
b.pathname = x.pathname; | ||
b.search = x.searchParams.toString(); | ||
b.hash = x.hash; | ||
return b; | ||
}); | ||
export const isURLPath = (u) => URL.isURL(u) && u.origin === phonyBase.origin; | ||
export const clone = over(URL.clone); | ||
export const fromURL = (x) => pipe(new globalThis.URL(x.href, phonyBase), (pack)); | ||
export const fromURL = (x) => pipe(new globalThis.URL(x.href, phonyBase), ensureBase, (pack)); | ||
export const toURL = (f) => (baseUrl) => (x) => E.tryCatch(() => new globalThis.URL(toString(x), baseUrl), e => f(e)); | ||
export const toURLO = (baseUrl) => flow(toURL(identity)(baseUrl), O.fromEither); | ||
export const fromString = (f) => (x) => pipe(E.tryCatch(() => { | ||
const y = new globalThis.URL(x, phonyBase); | ||
if (y.origin !== phonyBase) | ||
throw new TypeError("Failed to retain phony base URL"); | ||
return y; | ||
}, e => f(e)), E.map((pack))); | ||
export const fromString = (f) => (x) => pipe(E.tryCatch(() => ensureBase(new globalThis.URL(x, phonyBase)), e => f(e)), E.map((pack))); | ||
export const fromStringO = flow(fromString(identity), O.fromEither); | ||
export const fromPathname = (x) => { | ||
const y = new globalThis.URL("", phonyBase); | ||
const y = URL.clone(phonyBase); | ||
y.pathname = x; | ||
@@ -24,0 +25,0 @@ return pack(y); |
{ | ||
"name": "fp-ts-std", | ||
"description": "The missing pseudo-standard library for fp-ts.", | ||
"version": "0.19.0", | ||
"version": "0.19.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Sam A. Horvath-Hunt <hello@samhh.com>", |
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
540473
12016