Skip to content

Commit

Permalink
Support short URL redirects for Omer pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Apr 26, 2022
1 parent cfa3e1e commit 4abff43
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/rest-api",
"version": "3.13.1",
"version": "3.13.2",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand All @@ -21,7 +21,7 @@
"url": "https://github.com/hebcal/hebcal-rest-api/issues"
},
"dependencies": {
"@hebcal/core": "^3.35.0",
"@hebcal/core": "^3.36.2",
"@hebcal/leyning": "^4.13.2"
},
"scripts": {
Expand Down
17 changes: 16 additions & 1 deletion src/classic-rest-api.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import {HebrewCalendar, Location, DafYomiEvent, HDate, HebrewDateEvent, MishnaYomiEvent} from '@hebcal/core';
import {HebrewCalendar, Location, DafYomiEvent, HDate, HebrewDateEvent, MishnaYomiEvent, OmerEvent} from '@hebcal/core';
import {eventsToClassicApi, eventToClassicApiObject} from './classic-rest-api';

test('eventToClassicApiObject', (t) => {
Expand Down Expand Up @@ -465,3 +465,18 @@ test('location-zip', (t) => {
};
t.deepEqual(apiResult, expected);
});

test('omer', (t) => {
const ev = new OmerEvent(new HDate(2, 'Sivan', 5770), 46);
const obj = eventToClassicApiObject(ev, {}, false);
const expected = {
title: '46th day of the Omer',
date: '2010-05-15',
category: 'omer',
title_orig: 'Omer 46',
hebrew: 'עומר יום 46',
link: 'https://hebcal.com/o/5770/46?us=js&um=api',
memo: 'Eternity within Majesty\nנֶּֽצַח שֶׁבְּמַּלְכוּת\nNetzach sheb\'Malkhut',
};
t.deepEqual(obj, expected);
});
7 changes: 5 additions & 2 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,15 @@ export function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampai
const path = u.pathname;
const isHolidays = path.startsWith('/holidays/');
const isSedrot = path.startsWith('/sedrot/');
if (isHolidays || isSedrot) {
const isOmer = path.startsWith('/omer/');
if (isHolidays || isSedrot || isOmer) {
u.host = 'hebcal.com';
if (isHolidays) {
u.pathname = '/h/' + path.substring(10);
} else {
} else if (isSedrot) {
u.pathname = '/s/' + path.substring(8);
} else { // isOmer
u.pathname = '/o/' + path.substring(6);
}
if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
if (utmSource) {
Expand Down

0 comments on commit 4abff43

Please sign in to comment.