Launch Week Day 3: Introducing Organization Notifications in Socket.Learn More
Socket
Book a DemoSign in
Socket

psl

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

psl - npm Package Compare versions

Comparing version
1.11.0
to
1.12.0
+73
browserstack.yml
# ======================
# BrowserStack Reporting
# ======================
# The following capabilities are used to set up reporting on BrowserStack:
# Set 'projectName' to the name of your project. Example, Marketing Website
projectName: psl
# Set `buildName` as the name of the job / testsuite being run
buildName: browserstack build
# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
# buildName. Choose your buildIdentifier format from the available expressions:
# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
buildIdentifier: "#${BUILD_NUMBER}" # Supports strings along with either/both ${expression}
# =======================================
# Platforms (Browsers / Devices to test)
# =======================================
# Platforms object contains all the browser / device combinations you want to test on.
# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
platforms:
- os: Windows
osVersion: 11
browserName: chrome
browserVersion: latest
- os: OS X
osVersion: Ventura
browserName: playwright-webkit
browserVersion: latest
- os: Windows
osVersion: 11
browserName: playwright-firefox
browserVersion: latest
# =======================
# Parallels per Platform
# =======================
# The number of parallel threads to be used for each platform set.
# BrowserStack's SDK runner will select the best strategy based on the configured value
#
# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
#
# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
parallelsPerPlatform: 1
# ==========================================
# BrowserStack Local
# (For localhost, staging/private websites)
# ==========================================
# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
browserstackLocal: true # <boolean> (Default false)
# browserStackLocalOptions:
# Options to be passed to BrowserStack local in-case of advanced configurations
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
# forceLocal: true # <boolean> (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
framework: playwright
source: node-js-playwright-sample-sdk:v1
# ===================
# Debugging features
# ===================
debug: false # <boolean> # Set to true if you need screenshots for every selenium command ran
networkLogs: false # <boolean> Set to true to enable HAR logs capturing
consoleLogs: errors # <string> Remote browser's console debug levels to be printed (Default: errors)
# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors)
# CUSTOM_TAG_<INT>: # <string> (Default: parent folder name of the test file) Custom tag for your test suite
# Test Observability is an intelligent test reporting & debugging product. It collects data using the SDK. Read more about what data is collected at https://www.browserstack.com/docs/test-observability/references/terms-and-conditions
# Visit observability.browserstack.com to see your test reports and insights. To disable test observability, specify `testObservability: false` in the key below.
testObservability: true

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

module.exports = {
languageOptions: {
ecmaVersion: 2020,
},
rules: {
indent: [2, 2]
},
ignores: ['dist/*'],
};
// This is a sample config for what users might be running locally
const config = {
testDir: './test',
testMatch: '**/browserstack*.js',
/* Maximum time one test can run for. */
timeout: 90 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* tests in parallel */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'line',
/* Configure projects for major browsers */
projects: [
{
name: 'chrome',
use: {
browserName: 'chromium',
channel: 'chrome',
},
},
],
};
module.exports = config;
+13
-13

@@ -1,6 +0,8 @@

import Punycode from 'punycode/punycode.js';
/*eslint no-var:0, prefer-arrow-callback: 0, object-shorthand: 0 */
'use strict';
import rules from './data/rules.js';
var Punycode = require('punycode/');
var internals = {};

@@ -10,5 +12,5 @@

//
// Parse rules from file.
// Read rules from file.
//
internals.rules = rules.map(function (rule) {
internals.rules = require('./data/rules.json').map(function (rule) {

@@ -65,3 +67,3 @@ return {

//
export const errorCodes = {
exports.errorCodes = {
DOMAIN_TOO_SHORT: 'Domain name too short.',

@@ -141,3 +143,3 @@ DOMAIN_TOO_LONG: 'Domain name too long. It should be no more than 255 chars.',

//
export const parse = function (input) {
exports.parse = function (input) {

@@ -163,3 +165,3 @@ if (typeof input !== 'string') {

error: {
message: errorCodes[error],
message: exports.errorCodes[error],
code: error

@@ -255,3 +257,3 @@ }

//
export const get = function (domain) {
exports.get = function (domain) {

@@ -261,3 +263,3 @@ if (!domain) {

}
return parse(domain).domain || null;
return exports.parse(domain).domain || null;
};

@@ -269,8 +271,6 @@

//
export const isValid = function (domain) {
exports.isValid = function (domain) {
var parsed = parse(domain);
var parsed = exports.parse(domain);
return Boolean(parsed.domain && parsed.listed);
};
export default { parse, get, isValid };
{
"name": "psl",
"version": "1.11.0",
"version": "1.12.0",
"description": "Domain name parser based on the Public Suffix List",

@@ -9,10 +9,3 @@ "repository": {

},
"type": "module",
"exports": {
".": {
"import": "./dist/psl.mjs",
"require": "./dist/psl.cjs"
}
},
"types": "types/index.d.ts",
"main": "index.js",
"scripts": {

@@ -23,5 +16,6 @@ "lint": "eslint .",

"watch": "mocha test/*.spec.js --watch",
"update-rules": "./scripts/update-rules.js",
"build": "vite build",
"postbuild": "ln -s ./psl.umd.cjs dist/psl.js && ln -s ./psl.umd.cjs dist/psl.min.js",
"prebuild": "./scripts/update-rules.js",
"build": "browserify ./index.js --standalone=psl > ./dist/psl.js",
"postbuild": "cat ./dist/psl.js | uglifyjs -c -m > ./dist/psl.min.js",
"commit-and-pr": "commit-and-pr",
"changelog": "git log $(git describe --tags --abbrev=0)..HEAD --oneline --format=\"%h %s (%an <%ae>)\""

@@ -39,12 +33,13 @@ },

"devDependencies": {
"@eslint/js": "^9.15.0",
"@playwright/test": "^1.49.0",
"@types/eslint__js": "^8.42.3",
"browserstack-node-sdk": "^1.34.23",
"eslint": "^9.15.0",
"@playwright/test": "^1.48.2",
"browserify": "^17.0.1",
"browserstack-node-sdk": "^1.34.21",
"chai": "^5.1.2",
"commit-and-pr": "^1.0.4",
"eslint": "^9.14.0",
"JSONStream": "^1.3.5",
"mocha": "^10.8.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.15.0",
"vite": "^5.4.11"
"request": "^2.88.2",
"uglify-js": "^3.19.3"
}
}
}
+30
-81

@@ -33,62 +33,18 @@ # psl (Public Suffix List)

This module is available both for Node.js and the browser. See below for more
details.
### Node.js
```sh
npm install psl
npm install --save psl
```
#### ESM
From version `v1.11.0` you can now import `psl` as ESM.
```js
import psl from 'psl';
```
#### CommonJS
If your project still uses CommonJS on Node.js v12 or later (with support for
conditional exports), you can continue importing the module like in previous
versions.
```js
const psl = require('psl');
```
⚠️ If you are using Node.js v10 or older (😰), you can still use the latest
version of this module, but you will need to import the bundled UMD.
```js
var psl = require('psl/dist/psl.umd.cjs');
```
### Browser
#### Using a bundler
If you are using a bundler to build your app, you should be able to `import`
and/or `require` the module just like in Node.js.
#### ESM (using a CDN)
In modern browsers you can also import the ESM directly from a `CDN`. For
example:
```js
import psl from 'https://unpkg.com/psl@latest/dist/psl.mjs';
```
#### UMD / CommonJS
Finally, you can still download [`dist/psl.umd.cjs`](https://raw.githubusercontent.com/lupomontero/psl/main/dist/psl.umd.cjs)
Download [psl.min.js](https://raw.githubusercontent.com/lupomontero/psl/main/dist/psl.min.js)
and include it in a script tag.
```html
<script src="psl.umd.cjs"></script>
<script src="psl.min.js"></script>
```
This script is bundled and wrapped in a [umd](https://github.com/umdjs/umd)
This script is browserified and wrapped in a [umd](https://github.com/umdjs/umd)
wrapper so you should be able to use it standalone or together with a module

@@ -99,4 +55,4 @@ loader.

* https://cdnjs.cloudflare.com/ajax/libs/psl/latest/psl.min.js
* https://unpkg.com/psl@latest/dist/psl.min.js
* https://cdnjs.cloudflare.com/ajax/libs/psl/1.9.0/psl.min.js
* https://unpkg.com/psl@1.9.0/dist/psl.min.js

@@ -115,10 +71,9 @@ ## API

#### Examples
#### Example:
Parse domain without subdomain:
```js
import psl from 'psl';
var psl = require('psl');
const parsed = psl.parse('google.com');
// Parse domain without subdomain
var parsed = psl.parse('google.com');
console.log(parsed.tld); // 'com'

@@ -128,10 +83,5 @@ console.log(parsed.sld); // 'google'

console.log(parsed.subdomain); // null
```
Parse domain with subdomain:
```js
import psl from 'psl';
const parsed = psl.parse('www.google.com');
// Parse domain with subdomain
var parsed = psl.parse('www.google.com');
console.log(parsed.tld); // 'com'

@@ -141,10 +91,5 @@ console.log(parsed.sld); // 'google'

console.log(parsed.subdomain); // 'www'
```
Parse domain with nested subdomains:
```js
import psl from 'psl';
const parsed = psl.parse('a.b.c.d.foo.com');
// Parse domain with nested subdomains
var parsed = psl.parse('a.b.c.d.foo.com');
console.log(parsed.tld); // 'com'

@@ -160,6 +105,6 @@ console.log(parsed.sld); // 'foo'

#### Examples
#### Example:
```js
import psl from 'psl';
var psl = require('psl');

@@ -217,3 +162,3 @@ // null input.

```js
import psl from 'psl';
var psl = require('psl');

@@ -225,17 +170,19 @@ psl.isValid('google.com'); // true

## Testing and Building
There are tests both for Node.js and the browser (using [Playwright](https://playwright.dev)
and [BrowserStack](https://www.browserstack.com/)).
Test are written using [`mocha`](https://mochajs.org/) and can be
run in two different environments: `node` and `phantomjs`.
```sh
# Run tests in node.
# This will run `eslint`, `mocha` and `karma`.
npm test
# Run tests in browserstack.
npm run test:browserstack
# Update rules from publicsuffix.org
npm run update-rules
# Individual test environments
# Run tests in node only.
./node_modules/.bin/mocha test
# Run tests in phantomjs only.
./node_modules/.bin/karma start ./karma.conf.js --single-run
# Build ESM, CJS and UMD and create dist files
# Build data (parse raw list) and create dist files
npm run build

@@ -246,2 +193,3 @@ ```

## Acknowledgements

@@ -254,2 +202,3 @@

## License

@@ -259,3 +208,3 @@

Copyright (c) 2014-2024 Lupo Montero <lupomontero@gmail.com>
Copyright (c) 2017 Lupo Montero <lupomontero@gmail.com>

@@ -262,0 +211,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

// TypeScript Version: 2.4
/**
* Result returned when a given domain name was not parsable (not exported)
*/
export type ErrorResult<T extends keyof errorCodes> = {
input: string;
error: {
code: T;
message: errorCodes[T];
};
}
/**
* Error codes and descriptions for domain name parsing errors
*/
export const enum errorCodes {
DOMAIN_TOO_SHORT = 'Domain name too short',
DOMAIN_TOO_LONG = 'Domain name too long. It should be no more than 255 chars.',
LABEL_STARTS_WITH_DASH = 'Domain name label can not start with a dash.',
LABEL_ENDS_WITH_DASH = 'Domain name label can not end with a dash.',
LABEL_TOO_LONG = 'Domain name label should be at most 63 chars long.',
LABEL_TOO_SHORT = 'Domain name label should be at least 1 character long.',
LABEL_INVALID_CHARS = 'Domain name label can only contain alphanumeric characters or dashes.'
}
// Export the browser global variable name additionally to the CJS/AMD exports below
export as namespace psl;
export type ParsedDomain = {
input: string;
tld: string | null;
sld: string | null;
domain: string | null;
subdomain: string | null;
listed: boolean;
}
/**
* Parse a domain name and return its components
*/
export function parse(input: string): ParsedDomain | ErrorResult<keyof errorCodes>;
/**
* Get the base domain for full domain name
*/
export function get(domain: string): string | null;
/**
* Check whether the given domain belongs to a known public suffix
*/
export function isValid(domain: string): boolean;
import * as psl from 'psl';
import type { ParsedDomain, ErrorResult, errorCodes } from './index.d.ts';
const x = (a: ParsedDomain | ErrorResult<keyof errorCodes>) => {
return a;
};
console.log(x(psl.parse('')));
// $ExpectType string | null
console.log(psl.get('example.com'));
// $ExpectType boolean
console.log(psl.isValid('example.com'));
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es5"
],
"strict": true,
"noEmit": false,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
// Expose module under its CJS/AMD name
"baseUrl": ".",
"paths": {
"psl": [
"./index.d.ts"
]
}
}
}
import { resolve } from 'node:path';
import { defineConfig } from 'vite';
export default defineConfig({
build: {
target: 'es2015',
lib: {
entry: resolve(__dirname, 'index.js'),
name: 'psl',
formats: ['es', 'cjs', 'umd'],
fileName: format => (
format === 'umd'
? 'psl.umd.cjs'
: format === 'cjs'
? 'psl.cjs'
: 'psl.mjs'
),
},
},
});