Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed May 18, 2024
1 parent 00fb2d1 commit d1c85f0
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.16.3
VERSION=0.16.4
DATE=`date -uR`
YEAR=`date +%Y`

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
alt="Logo of Wayne library - it represents construction worker helmet and text with the name of the library" />
</h1>

[![npm](https://img.shields.io/badge/npm-0.16.3-blue.svg)](https://www.npmjs.com/package/@jcubic/wayne)
[![npm](https://img.shields.io/badge/npm-0.16.4-blue.svg)](https://www.npmjs.com/package/@jcubic/wayne)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://makeapullrequest.com)
[![jSDelivr](https://data.jsdelivr.com/v1/package/npm/@jcubic/wayne/badge)](https://www.jsdelivr.com/package/npm/@jcubic/wayne)

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Wayne - Server Worker Routing library (v. 0.16.3)
* Wayne - Server Worker Routing library (v. 0.16.4)
*
* Copyright (c) 2022-2024 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under MIT license
Expand Down
6 changes: 3 additions & 3 deletions index.min.js

Large diffs are not rendered by default.

41 changes: 35 additions & 6 deletions index.umd.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Wayne - Server Worker Routing library (v. 0.16.2)
* Wayne - Server Worker Routing library (v. 0.16.4)
*
* Copyright (c) 2022-2024 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under MIT license
*
* Mon, 01 Apr 2024 13:44:16 +0000
* Sat, 18 May 2024 21:40:20 +0000
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.wayne = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
Expand All @@ -19,14 +19,17 @@ exports.Wayne = void 0;
exports.rpc = rpc;
exports.send = send;
/*
* Wayne - Server Worker Routing library (v. 0.16.3)
* Wayne - Server Worker Routing library (v. 0.16.4)
*
* Copyright (c) 2022-2024 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under MIT license
*/

const root_url = get_root_path();
const root_url_re = new RegExp('^' + escape_re(root_url));
function same_origin(origin) {
return origin === self.location.origin;
}
function get_root_path() {
if (self.registration) {
const url = new URL(registration.scope);
Expand Down Expand Up @@ -88,6 +91,11 @@ function bind_fs(fs) {
}
return result;
}

// -----------------------------------------------------------------------------
// :: Wayne Route Response Class
// -----------------------------------------------------------------------------

class HTTPResponse {
constructor(resolve, reject) {
this._resolve = resolve;
Expand Down Expand Up @@ -195,8 +203,11 @@ class HTTPResponse {
}
}

// code based on https://github.com/jcubic/route.js
// Copyright (C) 2014-2017 Jakub T. Jankiewicz <https://jcubic.pl/me>
// -----------------------------------------------------------------------------
// :: Route Parser
// :: code based on https://github.com/jcubic/route.js
// :: Copyright (C) 2014-2017 Jakub T. Jankiewicz <https://jcubic.pl/me>
// -----------------------------------------------------------------------------
exports.HTTPResponse = HTTPResponse;
function RouteParser() {
const name_re = '[a-zA-Z_][a-zA-Z_0-9]*';
Expand Down Expand Up @@ -265,12 +276,16 @@ function RouteParser() {
for (let i = keys.length; i--;) {
const key = keys[i];
let pattern;
// check if origin match for full URL
if (key.match(/:\/\//)) {
const url = new URL(key);
if (url.origin !== origin) {
continue;
}
pattern = key.replace(url.origin, '');
} else if (!same_origin(origin)) {
// skip different origin
continue;
} else {
pattern = key;
}
Expand Down Expand Up @@ -372,6 +387,11 @@ async function list_dir({
return name;
}));
}

// -----------------------------------------------------------------------------
// :: File System
// -----------------------------------------------------------------------------

function FileSystem(options) {
let {
path,
Expand Down Expand Up @@ -403,7 +423,7 @@ function FileSystem(options) {
const url = new URL(req.url);
let path_name = normalize_url(decodeURIComponent(url.pathname));
url.pathname = path_name;
if (!(url.hostname === self.location.hostname && (await test(url)))) {
if (!(same_origin(url.origin) && (await test(url)))) {
return next();
}
if (req.method !== 'GET') {
Expand Down Expand Up @@ -444,6 +464,11 @@ function FileSystem(options) {
}
};
}

// -----------------------------------------------------------------------------
// :: Main Wayne Constructor
// -----------------------------------------------------------------------------

class Wayne {
constructor({
filter = () => true
Expand Down Expand Up @@ -536,6 +561,10 @@ class Wayne {
};
}
}

// -----------------------------------------------------------------------------
// :: RPC
// -----------------------------------------------------------------------------
exports.Wayne = Wayne;
function rpc(channel, methods) {
channel.addEventListener('message', async function handler(message) {
Expand Down
6 changes: 3 additions & 3 deletions index.umd.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jcubic/wayne",
"version": "0.16.3",
"version": "0.16.4",
"description": "Service Worker Routing for in browser HTTP requests",
"type": "module",
"main": "index.min.js",
Expand Down

0 comments on commit d1c85f0

Please sign in to comment.