Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Created May 9, 2021 08:38
Show Gist options
  • Select an option

  • Save tianhaoz95/b57cd6c2341b8cdb8137e82aa5c9e4e9 to your computer and use it in GitHub Desktop.

Select an option

Save tianhaoz95/b57cd6c2341b8cdb8137e82aa5c9e4e9 to your computer and use it in GitHub Desktop.
import {
UrlTranslatorRequest,
UrlTranslatorResponse,
UrlTranslator,
UrlTranslatorConfig,
} from "@wowlink/wow-interface";
class BasicUrlTranslator implements UrlTranslator {
config_: UrlTranslatorConfig;
constructor(config: UrlTranslatorConfig) {
this.config_ = config;
}
convert(req: UrlTranslatorRequest): UrlTranslatorResponse {
const lookup: Record<string, string> = this.config_.fetcherResponse.mapping;
const link: string = req.link;
const res: UrlTranslatorResponse = {
fullUrl: "/",
};
if (wowlink in lookup) {
res.fullUrl = lookup[wowlink];
}
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment