- From: Marcos Caceres <notifications@github.com>
- Date: Mon, 22 Dec 2014 17:24:08 -0800
- To: webspecs/url <url@noreply.github.com>
Received on Tuesday, 23 December 2014 01:24:38 UTC
So, instead of "subsumes", it might be easier to talk about some URL being "within scope" of some other URL. Testing Chrome's service worker implementation, if URL B's `.pathname` starts with URL's A's `.pathname`, it is "within scope": So: ``` //the scope algorithm could be: URL.inScope = function(a,b){ if (a === undefined || b === undefined){ return false; } //either A or B can throw. var A = new URL(String(a), window.location); var B = new URL(String(b), window.location); return B.pathname.startsWith(A.pathname); } //Given `a` as defining the scope a = "/t"; //These are all in scope of `a` ["/test-test/t", "/test", "/test-test", "/test-test/test"].every(i => URL.inScope(a, i)); //true //These are all out of scope [ "z", undefined, "z-test", "xyz123" ].every(i => !URL.inScope(a, i)); //true ``` --- Reply to this email directly or view it on GitHub: https://github.com/webspecs/url/issues/20#issuecomment-67912390
Received on Tuesday, 23 December 2014 01:24:38 UTC