You've already forked tf2wikipricing
refactor: move extractPageTitleFromURL to module, add tests
This commit is contained in:
8
src/content/utils/url.ts
Normal file
8
src/content/utils/url.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export function extractPageTitleFromURL(url: string): string {
|
||||
var split = url.substring(url.indexOf("/wiki/") + "/wiki/".length);
|
||||
if (split.indexOf('/') != -1) {
|
||||
// Remove language suffix (/es)
|
||||
split = split.substring(0, split.indexOf('/'));
|
||||
}
|
||||
return decodeURIComponent(split.replaceAll('_', ' '));
|
||||
}
|
||||
Reference in New Issue
Block a user