File tree Expand file tree Collapse file tree 8 files changed +85
-7
lines changed Expand file tree Collapse file tree 8 files changed +85
-7
lines changed Original file line number Diff line number Diff line change 1
1
/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */
2
2
3
- const testableUrls = new Map < string , string [ ] > ( ) ;
3
+ export const testableUrls = new Map < string , string [ ] > ( ) ;
4
4
5
5
export function addTests ( test : string , urls : string [ ] ) : void {
6
6
// @ts -expect-error KISS for Vite
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import * as urlDetection from ' ../index' ;
3
+ import { getTests } from ' ../collector' ;
4
+ </script >
5
+
6
+ <style >
7
+ pre , code {
8
+ white-space : nowrap ;
9
+ }
10
+ pre a {
11
+ color : inherit ;
12
+ }
13
+ </style >
14
+ {#each Object .keys (urlDetection ) as name }
15
+ {#if ! name .startsWith (' _' ) && name !== ' utils' }
16
+ <h2 id ={name }><a href ="# {name }" >{name }</a ></h2 >
17
+ {@const urls = getTests (name )}
18
+ {#if urls [0 ] === ' combinedTestOnly' }
19
+ <p ><em >Demo URLs missing</em ></p >
20
+ {:else if urls .length === 0 }
21
+ <p ><em >Undeterminable via URL</em ></p >
22
+ {:else }
23
+ <pre ><code >
24
+ {#each urls as url }
25
+ <a href ="/?url= {encodeURIComponent (url )}" >{url }</a ><br >
26
+ {/each }
27
+ </code ></pre >
28
+ {/if }
29
+ {/if }
30
+ {/each }
Original file line number Diff line number Diff line change 1
1
<script >
2
-
3
2
import parseUrl from ' ./parse-url.js' ;
4
3
import * as urlDetection from ' ../index' ;
5
- import { getAllUrls } from ' ../collector' ;
4
+ import { getAllUrls , testableUrls } from ' ../collector' ;
6
5
7
6
const defaultUrl = ' https://github.com/refined-github/github-url-detection' ;
8
7
const urlParameter = new URLSearchParams (location .search );
75
74
.undefined {
76
75
color : gray ;
77
76
}
77
+
78
+ pre a {
79
+ color : inherit ;
80
+ }
78
81
</style >
79
82
80
83
<label >
99
102
{#each detections as {name, detect, result} (name )}
100
103
{#if detect }
101
104
<div class ={String (result )}>
102
- {name }(url) // <span >{String (result )}</span ></div >
105
+ < a href = "/detections.html# {name }" >{ name }</ a > (url) // <span >{String (result )}</span ></div >
103
106
{:else }
104
107
<div class =" undefined" >
105
108
{name }() // undeterminable via URL</div >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ < link
6
+ rel ="stylesheet "
7
+ href ="https://unpkg.com/chota@0.7.2/dist/chota.min.css "
8
+ />
9
+ < meta name ="viewport " content ="width=device-width,initial-scale=1 " />
10
+
11
+ < title > `github-url-detection` detections</ title >
12
+
13
+ < link rel ="stylesheet " href ="global.css " />
14
+ < script defer type ="module " src ="detections.js "> </ script >
15
+ </ head >
16
+
17
+ < body >
18
+ < h1 >
19
+ < a href ="https://github.com/refined-github/github-url-detection ">
20
+ refined-github/github-url-detection
21
+ </ a >
22
+ </ h1 >
23
+ < main class ="container ">
24
+ </ main >
25
+ </ body >
26
+ </ html >
Original file line number Diff line number Diff line change
1
+ import Detections from './Detections.svelte' ;
2
+
3
+ const app = new Detections ( {
4
+ target : document . querySelector ( 'main' ) ,
5
+ } ) ;
6
+
7
+ export default app ;
Original file line number Diff line number Diff line change 11
11
< title > `github-url-detection` npm module testing ground</ title >
12
12
13
13
< link rel ="stylesheet " href ="global.css " />
14
- < script defer type ="module " src ="main .js "> </ script >
14
+ < script defer type ="module " src ="index .js "> </ script >
15
15
</ head >
16
16
17
17
< body >
Original file line number Diff line number Diff line change 1
- import App from './App .svelte' ;
1
+ import Index from './Index .svelte' ;
2
2
3
- const app = new App ( {
3
+ const app = new Index ( {
4
4
target : document . querySelector ( 'main' ) ,
5
5
} ) ;
6
6
Original file line number Diff line number Diff line change
1
+ import { resolve } from 'node:path' ;
2
+ import * as url from 'node:url' ;
1
3
import { defineConfig } from 'vite' ;
2
4
import { svelte } from '@sveltejs/vite-plugin-svelte' ;
3
5
6
+ const __dirname = url . fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
7
+
4
8
export default defineConfig ( {
5
9
base : '' ,
6
10
plugins : [ svelte ( ) ] ,
11
+ build : {
12
+ rollupOptions : {
13
+ input : {
14
+ main : resolve ( __dirname , 'index.html' ) ,
15
+ nested : resolve ( __dirname , 'detections.html' ) ,
16
+ } ,
17
+ } ,
18
+ } ,
7
19
} ) ;
You can’t perform that action at this time.
0 commit comments