@bitovi/calendar-events-component
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -162,3 +162,3 @@ // jshint ignore: start | ||
eventEls[1].querySelector(".event-body").innerHTML, | ||
"IN PERSON ChicagoJS Meetup<br><br>See all the details and RSVP here: <a href=\"https://www.google.com/url?q=https://www.meetup.com/js-chi/events/288515502/&sa=D&source=calendar&ust=1680538571058455&usg=AOvVaw1Uqtg1pPsvsyv6sfG4NFK7\" target=\"_blank\">https://www.meetup.com/js-chi/events/288515502/</a>", | ||
"IN PERSON ChicagoJS Meetup<br><br>See all the details and RSVP here: <a href=\"https://www.meetup.com/js-chi/events/288515502/\" target=\"_blank\">https://www.meetup.com/js-chi/events/288515502/</a>", | ||
"body information correctly parsed & inserted" | ||
@@ -372,2 +372,3 @@ ) | ||
return Object.assign({}, eventSkel, { | ||
summary: title, | ||
organizer: { email: "b4@gro.testdata", self: true, displayName: title }, | ||
@@ -385,3 +386,3 @@ description, | ||
createEvent("test event-date", `Test Description 1`, { dateTime: new Date("Apr 7, 2023, 6:30 PM").toISOString() }), | ||
createEvent("test event-date", `Test Description 2`, { date: new Date("Tue, Apr 18, 2023").toISOString() }) | ||
// createEvent("test event-date", `Test Description 2`, { date: new Date("Tue, Apr 18, 2023").toISOString() }) | ||
] | ||
@@ -609,2 +610,34 @@ }) | ||
QUnit.test('Component correctly uses custom event-date field and its variants', async assert => { | ||
globalThis.fetch = () => Promise.resolve({ | ||
json: () => ({ | ||
items: [ | ||
createEvent("free redirect captured description links", 'IN PERSON ChicagoJS Meetup\u003cbr\u003e\u003cbr\u003eSee all the details and RSVP here: \u003ca href="https://www.google.com/url?q=https://www.meetup.com/js-chi/events/288515502/&sa=D&source=calendar&ust=1680538571058455&usg=AOvVaw1Uqtg1pPsvsyv6sfG4NFK7" target="_blank"\u003ehttps://www.meetup.com/js-chi/events/288515502/\u003c/a\u003e'), | ||
createEvent("no redirect to free here", "Join us for our online meetup where we have a handful of short talks on a variety of interesting topics!\n\nBitovi Meetup: https://www.bitovi.com/community"), | ||
createEvent("free redirect captured description links", '\u003cb\u003eYour Unique Join Link:\u003c/b\u003e \u003ca href="https://www.google.com/url?q=https://my.demio.com/manage-registration/uc2cYcFAlOyciRxT&sa=D&source=calendar&ust=1680538560648920&usg=AOvVaw0zgJBlyXo8r5EIgnJKNclq" target="_blank"\u003eManage registration and notifications\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e') | ||
] | ||
}) | ||
}) | ||
fixture.innerHTML = ` | ||
<calendar-events | ||
api-key="AIzaSyBsNpdGbkTsqn1BCSPQrjO9OaMySjK5Sns" | ||
calendar-id="jupiterjs.com_g27vck36nifbnqrgkctkoanqb4@group.calendar.google.com" | ||
event-count="3" | ||
show-recurring | ||
></calendar-events> | ||
` | ||
const el = select("calendar-events") | ||
await el.promise | ||
const links = el.querySelectorAll('.event-body a') | ||
assert.equal(links.length, 3, "all links inserted") | ||
assert.equal(links[0].href, "https://www.meetup.com/js-chi/events/288515502/", "url 1 is correct") | ||
assert.equal(links[1].href, "https://www.bitovi.com/community", "url 2 is correct") | ||
assert.equal(links[2].href, "https://my.demio.com/manage-registration/uc2cYcFAlOyciRxT", "url 3 is correct") | ||
}) | ||
/* | ||
@@ -611,0 +644,0 @@ .event-location // needs tests, does link substitution stuff, had a bug |
@@ -89,10 +89,7 @@ function safeCustomElement(tag, constructor, prototype) { | ||
var description = (event.description || '').trim(); | ||
// var lines, last; | ||
// var isHTML = description.includes("<br>"); | ||
// if (isHTML) { | ||
// lines = description.split(/<br\/?>/); | ||
// } else { | ||
// lines = description.split(/\r?\n/); | ||
// } | ||
// last = lines.pop() || ''; | ||
const hasHTML = /<\/?(?:a|b|p|span|br)>/.test(description); | ||
if (!hasHTML) { | ||
description = linkify(description.replace(/\r?\n/g, "<br />")); | ||
} | ||
var url = event.htmlLink; | ||
@@ -183,2 +180,10 @@ | ||
} | ||
function stripRedirectCapture(container) { | ||
selectAllIncludeSelf(container, "a[href^='https://www.google.com/url?']").forEach(function (a) { | ||
const captured = a.href.replace("https://www.google.com/url?", "").split("&").find(s => s.startsWith("q=")); | ||
const freed = captured ? decodeURIComponent(captured.replace("q=", "")) : a.href; | ||
a.href = freed; | ||
// if a captured link contains "&" in its own url, this may need to change depending on how they encoded it | ||
}); | ||
} | ||
function dataFindThenCutOrCopy(container, dataFindRegEx) { | ||
@@ -367,2 +372,4 @@ selectAllIncludeSelf(container, "a.event-body, .event-body a").forEach(function (link) { | ||
stripRedirectCapture(container); | ||
findTerms && dataFindThenCutOrCopy(container, dataFindRegEx); // requires .event-body to be populated first | ||
@@ -369,0 +376,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*@bitovi/calendar-events-component@0.1.0#calendar-events*/ | ||
/*@bitovi/calendar-events-component@0.2.0#calendar-events*/ | ||
define(function (require, exports, module) { | ||
@@ -77,2 +77,6 @@ function safeCustomElement(tag, constructor, prototype) { | ||
var description = (event.description || '').trim(); | ||
const hasHTML = /<\/?(?:a|b|p|span|br)>/.test(description); | ||
if (!hasHTML) { | ||
description = linkify(description.replace(/\r?\n/g, '<br />')); | ||
} | ||
var url = event.htmlLink; | ||
@@ -144,2 +148,9 @@ return { | ||
} | ||
function stripRedirectCapture(container) { | ||
selectAllIncludeSelf(container, 'a[href^=\'https://www.google.com/url?\']').forEach(function (a) { | ||
const captured = a.href.replace('https://www.google.com/url?', '').split('&').find(s => s.startsWith('q=')); | ||
const freed = captured ? decodeURIComponent(captured.replace('q=', '')) : a.href; | ||
a.href = freed; | ||
}); | ||
} | ||
function dataFindThenCutOrCopy(container, dataFindRegEx) { | ||
@@ -285,2 +296,3 @@ selectAllIncludeSelf(container, 'a.event-body, .event-body a').forEach(function (link) { | ||
setHtmlContent(container, '.event-body', metaData.descriptionHTML); | ||
stripRedirectCapture(container); | ||
findTerms && dataFindThenCutOrCopy(container, dataFindRegEx); | ||
@@ -287,0 +299,0 @@ return container; |
@@ -1,2 +0,2 @@ | ||
/*@bitovi/calendar-events-component@0.1.0#calendar-events*/ | ||
/*@bitovi/calendar-events-component@0.2.0#calendar-events*/ | ||
function safeCustomElement(tag, constructor, prototype) { | ||
@@ -76,2 +76,6 @@ prototype = prototype || constructor.prototype; | ||
var description = (event.description || '').trim(); | ||
const hasHTML = /<\/?(?:a|b|p|span|br)>/.test(description); | ||
if (!hasHTML) { | ||
description = linkify(description.replace(/\r?\n/g, '<br />')); | ||
} | ||
var url = event.htmlLink; | ||
@@ -143,2 +147,9 @@ return { | ||
} | ||
function stripRedirectCapture(container) { | ||
selectAllIncludeSelf(container, 'a[href^=\'https://www.google.com/url?\']').forEach(function (a) { | ||
const captured = a.href.replace('https://www.google.com/url?', '').split('&').find(s => s.startsWith('q=')); | ||
const freed = captured ? decodeURIComponent(captured.replace('q=', '')) : a.href; | ||
a.href = freed; | ||
}); | ||
} | ||
function dataFindThenCutOrCopy(container, dataFindRegEx) { | ||
@@ -284,2 +295,3 @@ selectAllIncludeSelf(container, 'a.event-body, .event-body a').forEach(function (link) { | ||
setHtmlContent(container, '.event-body', metaData.descriptionHTML); | ||
stripRedirectCapture(container); | ||
findTerms && dataFindThenCutOrCopy(container, dataFindRegEx); | ||
@@ -286,0 +298,0 @@ return container; |
@@ -168,3 +168,3 @@ /*[process-shim]*/ | ||
/*@bitovi/calendar-events-component@0.1.0#calendar-events*/ | ||
/*@bitovi/calendar-events-component@0.2.0#calendar-events*/ | ||
define('@bitovi/calendar-events-component', function (require, exports, module) { | ||
@@ -245,2 +245,6 @@ function safeCustomElement(tag, constructor, prototype) { | ||
var description = (event.description || '').trim(); | ||
const hasHTML = /<\/?(?:a|b|p|span|br)>/.test(description); | ||
if (!hasHTML) { | ||
description = linkify(description.replace(/\r?\n/g, '<br />')); | ||
} | ||
var url = event.htmlLink; | ||
@@ -312,2 +316,9 @@ return { | ||
} | ||
function stripRedirectCapture(container) { | ||
selectAllIncludeSelf(container, 'a[href^=\'https://www.google.com/url?\']').forEach(function (a) { | ||
const captured = a.href.replace('https://www.google.com/url?', '').split('&').find(s => s.startsWith('q=')); | ||
const freed = captured ? decodeURIComponent(captured.replace('q=', '')) : a.href; | ||
a.href = freed; | ||
}); | ||
} | ||
function dataFindThenCutOrCopy(container, dataFindRegEx) { | ||
@@ -453,2 +464,3 @@ selectAllIncludeSelf(container, 'a.event-body, .event-body a').forEach(function (link) { | ||
setHtmlContent(container, '.event-body', metaData.descriptionHTML); | ||
stripRedirectCapture(container); | ||
findTerms && dataFindThenCutOrCopy(container, dataFindRegEx); | ||
@@ -455,0 +467,0 @@ return container; |
{ | ||
"name": "@bitovi/calendar-events-component", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "custom element that shows a google calendar", | ||
@@ -44,2 +44,2 @@ "homepage": "http://bitovi.com", | ||
"license": "MIT" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
376110
2000
6