Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@internetarchive/search-service

Package Overview
Dependencies
Maintainers
11
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internetarchive/search-service - npm Package Compare versions

Comparing version 0.0.1-alpha.4 to 0.0.1-alpha.5

4

dist/src/models/metadata-fields/field-parsers.js

@@ -38,2 +38,6 @@ export class NumberParser {

parseJSDate(rawValue) {
// fix for Safari not supporting `yyyy-mm-dd HH:MM:SS` format, insert a `T` into the space
if (rawValue.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s{1}[0-9]{2}:[0-9]{2}:[0-9]{2}$/)) {
rawValue = rawValue.replace(' ', 'T');
}
const parsed = Date.parse(rawValue);

@@ -40,0 +44,0 @@ if (Number.isNaN(parsed)) {

@@ -46,2 +46,3 @@ import { expect } from '@open-wc/testing';

const response = parser.parseValue('2020-06-20 3:46:23');
const response2 = parser.parseValue('2020-06-20 03:46:23');
const expected = new Date();

@@ -56,3 +57,17 @@ expected.setUTCHours(3);

expect(response === null || response === void 0 ? void 0 : response.getTime()).to.equal(expected.getTime());
expect(response2 === null || response2 === void 0 ? void 0 : response2.getTime()).to.equal(expected.getTime());
});
it('can parse date-time strings different string test', async () => {
const parser = new DateParser();
const response = parser.parseValue('2020-09-20 05:12:38');
const expected = new Date();
expected.setUTCHours(5);
expected.setUTCMinutes(12);
expected.setUTCSeconds(38);
expected.setUTCMilliseconds(0);
expected.setUTCMonth(8);
expected.setUTCDate(20);
expected.setUTCFullYear(2020);
expect(response === null || response === void 0 ? void 0 : response.getTime()).to.equal(expected.getTime());
});
it('can parse ISO8601 strings', async () => {

@@ -63,2 +78,3 @@ const parser = new DateParser();

const response3 = parser.parseValue('2020-06-20T13:37:15-00:00');
const response4 = parser.parseValue('2020-06-20T13:37:15+00:00');
const expected = new Date();

@@ -75,2 +91,3 @@ expected.setUTCHours(13);

expect(response3 === null || response3 === void 0 ? void 0 : response3.getTime()).to.equal(expected.getTime());
expect(response4 === null || response4 === void 0 ? void 0 : response4.getTime()).to.equal(expected.getTime());
});

@@ -77,0 +94,0 @@ it('can parse "c.a. yyyy" formatted dates', async () => {

2

package.json
{
"name": "@internetarchive/search-service",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.5",
"description": "A search service for the Internet Archive",

@@ -5,0 +5,0 @@ "license": "AGPL-3.0-only",

@@ -50,2 +50,11 @@ /* eslint-disable class-methods-use-this */

private parseJSDate(rawValue: string): Date | undefined {
// fix for Safari not supporting `yyyy-mm-dd HH:MM:SS` format, insert a `T` into the space
if (
rawValue.match(
/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s{1}[0-9]{2}:[0-9]{2}:[0-9]{2}$/
)
) {
rawValue = rawValue.replace(' ', 'T');
}
const parsed = Date.parse(rawValue);

@@ -52,0 +61,0 @@ if (Number.isNaN(parsed)) {

@@ -59,2 +59,3 @@ import { expect } from '@open-wc/testing';

const response = parser.parseValue('2020-06-20 3:46:23');
const response2 = parser.parseValue('2020-06-20 03:46:23');
const expected = new Date();

@@ -69,4 +70,19 @@ expected.setUTCHours(3);

expect(response?.getTime()).to.equal(expected.getTime());
expect(response2?.getTime()).to.equal(expected.getTime());
});
it('can parse date-time strings different string test', async () => {
const parser = new DateParser();
const response = parser.parseValue('2020-09-20 05:12:38');
const expected = new Date();
expected.setUTCHours(5);
expected.setUTCMinutes(12);
expected.setUTCSeconds(38);
expected.setUTCMilliseconds(0);
expected.setUTCMonth(8);
expected.setUTCDate(20);
expected.setUTCFullYear(2020);
expect(response?.getTime()).to.equal(expected.getTime());
});
it('can parse ISO8601 strings', async () => {

@@ -77,2 +93,3 @@ const parser = new DateParser();

const response3 = parser.parseValue('2020-06-20T13:37:15-00:00');
const response4 = parser.parseValue('2020-06-20T13:37:15+00:00');
const expected = new Date();

@@ -89,2 +106,3 @@ expected.setUTCHours(13);

expect(response3?.getTime()).to.equal(expected.getTime());
expect(response4?.getTime()).to.equal(expected.getTime());
});

@@ -91,0 +109,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc