Skip to content

Commit

Permalink
add some @codecs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhiggs committed Aug 23, 2024
2 parents 0353843 + 719265c commit cb51780
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16
FROM node:20
COPY ./ /usr/src/app
WORKDIR /usr/src/app
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./selfsigned.key -out selfsigned.crt -subj "/C=US/ST=New Sweden/L=Stockholm/O=.../OU=.../CN=.../emailAddress=..."
Expand Down
2 changes: 1 addition & 1 deletion URI_checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { datatypeIs } from "./phlib/phlib.js";
// RFC 4151 compliant - https://tools.ietf.org/html/rfc4151
// tagURI = "tag:" taggingEntity ":" specific [ "#" fragment ]
const TagRegex = new RegExp(
"^tag:(([\\da-z\\-\\._]+@)?[\\da-z][\\da-z-]*[\\da-z]*(\\.[\\da-z][\\da-z\\-]*[\\da-z]*)*),\\d{4}(\\-\\d{2}(\\-\\d{2})?)?:(['a-z\\d-\\._~!$&\\(\\)\\*\\+,;=:@\\?/]|%[0-9a-f]{2})*(#(['a-z0-9\\-\\._~!$&\\(\\)\\*\\+,;=:@\\?/]|%[0-9a-f]{2})*)?$",
/^tag:(([\da-z\-._]+@)?[\da-z][\da-z-]*[\da-z]*(\.[\da-z][\da-z-]*[\da-z]*)*),\d{4}(-\d{2}(\-\d{2})?)?:(['a-z\d-._~!$&()*+,;=:@?/]|%[0-9a-f]{2})*(#(['a-z0-9\-._~!$&()*+,;=:@\\?/]|%[0-9a-f]{2})*)?$/,
"i"
);
export let isTAGURI = (identifier) => (datatypeIs(identifier, "string") ? TagRegex.test(identifier.trim()) : false);
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
environment:
- no_proxy=localhost,127.0.0.1
volumes:
- ./:/usr/src/app
- "${GIT_CLONE_PATH:-./}:/usr/src/app"
- node_modules:/usr/src/app/node_modules
ports:
- "3030:3030"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"url": "https://github.com/paulhiggs/dvb-i-tools"
},
"devDependencies": {
"eslint": "^8.39.0"
"eslint": "^9.9.0"
}
}
3 changes: 2 additions & 1 deletion pattern_checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export let isRatioType = (str) => (datatypeIs(str, "string") ? ratioRegex.test(s
* @param {string} str string contining the UTC time
* @returns {boolean} true if the argment is formatted according to UTC ("Zulu") time
*/
const UTCregex = new RegExp(/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]+)?(Z)?$/);
const UTCregex = new RegExp(/^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]{1,3})?Z?$/);
export let isUTCDateTime = (str) => (datatypeIs(str, "string") ? UTCregex.test(str.trim()) : false);

/**
Expand Down Expand Up @@ -222,6 +222,7 @@ export let validServiceDaysList = (daysList) => (datatypeIs(daysList, "string")
* @param {string} val the value to check, likely from an Interval@startTime or @endTime attributes
* @returns {boolean} true if the value is properly formated
*/

const ZuluRegex = new RegExp(/^(([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?)Z$/);
export let validZuluTimeType = (time) => (datatypeIs(time, "string") ? ZuluRegex.test(time.trim()) : false);

Expand Down
17 changes: 17 additions & 0 deletions test/input/test-001/test-re2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ import {
isURN,
isHTTPURL,
validZuluTimeType,
isUTCDateTime,
} from "../../../pattern_checks.js";

<<<<<<< HEAD
const AVCregex = /[a-z0-9!\"#$%&'()*+,./:;<=>?@[\] ^_`{|}~-]{4}\.[a-f0-9]{6}/i;
const AC4regex = /ac-4(\.[a-fA-F\d]{1,2}){3}/;
const VP9regex = /^vp09(\.\d{2}){3}(\.(\d{2})?){0,5}$/;

const AV1regex = /^av01\.\d\.\d+[MH]\.\d{1,2}((\.\d?)(\.(\d{3})?(\.(\d{2})?(.(\d{2})?(.(\d{2})?(.\d?)?)?)?)?)?)?$/;
=======
import {isTAGURI} from "../../../URI_checks.js";
>>>>>>> 719265c9b8bd33848f29523b9ccfc41214d2c544

const ConsoleColours = {
Reset: "\x1b[0m",
Expand Down Expand Up @@ -202,6 +207,18 @@ const tests0 = [
{ item: "ztime-52", fn: validZuluTimeType, evaluate: "09:30-05:00", expect: false },
{ item: "ztime-53", fn: validZuluTimeType, evaluate: "09:30+08:30", expect: false },
{ item: "ztime-54", fn: validZuluTimeType, evaluate: "09:30+12", expect: false },

{item: "ztime-55", fn:isUTCDateTime, evaluate: "2024-08-20T12:45:15.000Z", expect: true},
{item: "ztime-56", fn:isUTCDateTime, evaluate: "2024-08-20T12:45:15Z", expect: true},
{item: "ztime-57", fn:isUTCDateTime, evaluate: "2014-07-15T20:42:30Z", expect: true},

{item: "taguri-1", fn: isTAGURI, evaluate: "tag:sandt.com:uk,2023:SandT‑Service‑1", expect: false},
{item: "taguri-2", fn: isTAGURI, evaluate: "tag:sandt.com.uk,2023:SandT‑Service‑1", expect: false},
{item: "taguri-3", fn: isTAGURI, evaluate: "tag:sandt.com.uk,2023:SandT-Service-1", expect: true},
{item: "taguri-4", fn: isTAGURI, evaluate: "tag:sandt.com.uk,2023:SandT‑Service‑1‑The Legend of Boggy Creek (1972)", expect: false},
{item: "taguri-5", fn: isTAGURI, evaluate: "tag:sandt.com.uk,2023:SandT-Service-1-The%20Legend%20of%20Boggy%20Creek%20(1972)", expect: true},


];

const tests1 = [
Expand Down

0 comments on commit cb51780

Please sign in to comment.