cbst 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ # 0.2.2
4
+
5
+ - Fix CLI exit code
6
+ - Fix `exclude` not excluding some references
7
+ - Fix identification of external references
8
+
3
9
  # 0.2.1
4
10
 
5
11
  - Ignore `mailto:` and other protocols properly
@@ -78,6 +78,7 @@ export declare class CacheBuster extends EventEmitter {
78
78
  handleReferenceError(error: Error, source: string, reference: string): void;
79
79
  getReferences(file: string): Promise<string[]>;
80
80
  isResolvableReference(reference: string): boolean;
81
+ isExternalReference(reference: string): boolean;
81
82
  resolveReference(base: string, reference: string): string;
82
83
  getBase(file: string): Promise<string>;
83
84
  formatVersion(hash: string): string;
@@ -21,7 +21,7 @@ class CacheBuster extends events_1.default {
21
21
  this.map = new Map();
22
22
  this.unresolved = new Map();
23
23
  this.referenceRx = /((")(([^"\s]+)\.([a-zA-Z0-9]+))")|((')(([^'\s]+)\.([a-zA-Z0-9]+))')|# sourceMappingURL=(([^\s]+)\.([a-zA-Z0-9]+))/g;
24
- this.externalReferenceRx = /^([a-zA-Z0-9]+:|\/\/)/;
24
+ this.externalReferenceRx = /^([a-zA-Z][a-zA-Z0-9+.\-]*:|\/\/)/;
25
25
  this.baseRx = /<base[^<>]+href\s*=\s*"([^"]+)"[^<>]*>/i;
26
26
  this.extensionRx = /(?<=\.)[^.]+$/;
27
27
  const o = { ...CacheBuster.defaultConfig, ...options };
@@ -151,7 +151,10 @@ class CacheBuster extends events_1.default {
151
151
  return references;
152
152
  }
153
153
  isResolvableReference(reference) {
154
- return !reference.match(this.externalReferenceRx);
154
+ return (!this.isExternalReference(reference) && !this.excludeGlob.match(reference));
155
+ }
156
+ isExternalReference(reference) {
157
+ return !!reference.match(this.externalReferenceRx);
155
158
  }
156
159
  resolveReference(base, reference) {
157
160
  if (reference[0] === '/')
package/dist/bin.js CHANGED
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const CacheBusterCli_1 = require("./CacheBusterCli");
5
5
  const cli = new CacheBusterCli_1.CacheBusterCli();
6
- cli.run(process.argv.slice(2));
6
+ cli.run(process.argv.slice(2)).then((exitCode) => process.exit(exitCode));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbst",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "A cache buster that versions a website's files for immutable cache control",
5
5
  "keywords": [
6
6
  "versioning",