Skip to content

Commit

Permalink
build: avoid exports field
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 28, 2022
1 parent 2ebb075 commit 86ef25f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 7 additions & 9 deletions package.json
Expand Up @@ -3,8 +3,8 @@
"description": "Check if an URL is a valid HTTP URL.",
"homepage": "https://nicedoc.io/Kikobeats/is-url-http",
"version": "2.3.0",
"browser": "src/lightweight.js",
"main": "src/index.js",
"browser": "lightweight.js",
"main": "index.js",
"author": {
"email": "josefrancisco.verdu@gmail.com",
"name": "Kiko Beats",
Expand Down Expand Up @@ -33,7 +33,7 @@
"whatwg"
],
"dependencies": {
"url-http": "~1.0.1"
"url-http": "~1.0.2"
},
"devDependencies": {
"@commitlint/cli": "latest",
Expand All @@ -56,7 +56,9 @@
"node": ">= 8"
},
"files": [
"src"
"index.d.ts",
"index.js",
"lightweight.js"
],
"scripts": {
"clean": "rm -rf node_modules",
Expand All @@ -79,10 +81,6 @@
"@commitlint/config-conventional"
]
},
"exports": {
".": "./src/index.js",
"./lightweight": "./src/lightweight.js"
},
"nano-staged": {
"*.js,!*.min.js,": [
"prettier-standard"
Expand All @@ -98,7 +96,7 @@
"commit-msg": "npx commitlint --edit",
"pre-commit": "npx nano-staged"
},
"types": "src/index.d.ts",
"types": "index.d.ts",
"umd:main": "lightweight.js",
"unpkg": "lightweight.js"
}
55 changes: 27 additions & 28 deletions test/index.js
Expand Up @@ -2,33 +2,32 @@

const test = require('ava')

;[
{ fn: require('is-url-http') },
{ fn: require('is-url-http/lightweight'), isLightweight: true }
].forEach(({ fn: isHttpUrl, isLightweight }) => {
test(isLightweight ? 'lightweight » true' : 'true', t => {
t.true(isHttpUrl('http://kikobeats.com'))
t.true(isHttpUrl("https://en.wikipedia.org/wiki/Amdahl's_law"))
t.true(isHttpUrl('https://kikobeats.com'))
t.true(isHttpUrl('https://www.kikobeats.com'))
t.true(isHttpUrl('https://en.wikipedia.org/wiki/Saw_(disambiguation)'))
t.true(isHttpUrl('http://www.kikobeats.com'))
t.true(
isHttpUrl(
'http://www.ccrscenter.org/sites/default/files/CCRS%20District%20Practices%20Brief.pdf'
;[{ fn: require('..') }, { fn: require('../lightweight'), isLightweight: true }].forEach(
({ fn: isHttpUrl, isLightweight }) => {
test(isLightweight ? 'lightweight » true' : 'true', t => {
t.true(isHttpUrl('http://kikobeats.com'))
t.true(isHttpUrl("https://en.wikipedia.org/wiki/Amdahl's_law"))
t.true(isHttpUrl('https://kikobeats.com'))
t.true(isHttpUrl('https://www.kikobeats.com'))
t.true(isHttpUrl('https://en.wikipedia.org/wiki/Saw_(disambiguation)'))
t.true(isHttpUrl('http://www.kikobeats.com'))
t.true(
isHttpUrl(
'http://www.ccrscenter.org/sites/default/files/CCRS%20District%20Practices%20Brief.pdf'
)
)
)
})
})

test(isLightweight ? 'lightweight » false' : 'false', t => {
if (!isLightweight) t.false(isHttpUrl('http://Http://kikobeats.com'))
t.false(isHttpUrl('https://. • 3.7M views'))
t.false(isHttpUrl())
t.false(isHttpUrl('callto://'))
t.false(isHttpUrl('mailto://'))
t.false(isHttpUrl('httpsucks://lol.wtf'))
if (!isLightweight) t.false(isHttpUrl('https://admin:admin@test-http-login.vercel.app'))
if (!isLightweight) t.false(isHttpUrl('http:!!!\0'))
if (!isLightweight) t.false(isHttpUrl('http://-kikobeats.com'))
})
})
test(isLightweight ? 'lightweight » false' : 'false', t => {
if (!isLightweight) t.false(isHttpUrl('http://Http://kikobeats.com'))
t.false(isHttpUrl('https://. • 3.7M views'))
t.false(isHttpUrl())
t.false(isHttpUrl('callto://'))
t.false(isHttpUrl('mailto://'))
t.false(isHttpUrl('httpsucks://lol.wtf'))
if (!isLightweight) t.false(isHttpUrl('https://admin:admin@test-http-login.vercel.app'))
if (!isLightweight) t.false(isHttpUrl('http:!!!\0'))
if (!isLightweight) t.false(isHttpUrl('http://-kikobeats.com'))
})
}
)

0 comments on commit 86ef25f

Please sign in to comment.