-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(webserver): remove /resolve/meta api endpoint (#1816)
* refactor(webserver): remove /resolve/meta api endpoint * feat(ui): detect language by filename * update * move filename2prism to @/lib * [autofix.ci] apply automated fixes --------- Co-authored-by: liangfung <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2aa4520
commit f852da9
Showing
16 changed files
with
951 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Fork from | ||
// https://github.com/TomerAberbach/filename2prism/ | ||
|
||
import path from 'path' | ||
import { has } from 'lodash-es' | ||
|
||
import languages from './languages' | ||
|
||
const filenames: Record<string, string[]> = {} | ||
const extnames: Record<string, string[]> = {} | ||
|
||
for (const [alias, associations] of Object.entries(languages)) { | ||
for (const filename of associations.filenames) { | ||
if (!has(filenames, filename)) { | ||
filenames[filename] = [] | ||
} | ||
|
||
filenames[filename].push(alias) | ||
} | ||
|
||
for (const extname of associations.extnames) { | ||
if (!has(extnames, extname)) { | ||
extnames[extname] = [] | ||
} | ||
|
||
extnames[extname].push(alias) | ||
} | ||
} | ||
|
||
const filename2prism: (filename: string) => Array<string> = filename => { | ||
const result: string[] = [] | ||
return result | ||
.concat( | ||
filenames[path.basename(filename)], | ||
extnames[path.extname(filename).substring(1)] | ||
) | ||
.filter(Boolean) | ||
} | ||
|
||
export default filename2prism |
Oops, something went wrong.