Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LinkFinder {
- constructor(data, includePrefix, path) {
- this.data = data;
- this.includePrefix = includePrefix;
- this.includeSuffix = checkIfDataNeedsSuffix(this.data.foobar);
- this.path = path;
- }
- urlFor(environment) {
- if (environment === 'dev') {
- if (this.includeSuffix) {
- return null;
- }
- if (this.includePrefix) {
- return URI.expand(DEV_WITH_PREFIX, this.data).toString();
- } else {
- return URI.expand(DEV_WITHOUT_PREFIX, this.data).toString();
- }
- }
- if (environment === 'int') {
- if (this.includeSuffix) {
- return null;
- }
- if (this.includePrefix) {
- return URI.expand(INT_WITH_PREFIX, this.data).toString();
- } else {
- return URI.expand(INT_WITHOUT_PREFIX, this.data).toString();
- }
- }
- if (environment === 'prod') {
- if (this.includeSuffix) {
- return null;
- }
- if (this.includePrefix) {
- return URI.expand(PROD_WITH_PREFIX, this.data).toString();
- } else {
- return URI.expand(PROD_WITHOUT_PREFIX, this.data).toString();
- }
- }
- if (environment === 'stage') {
- if (this.includeSuffix) {
- if (this.includePrefix) {
- return URI.expand(STAGE_WITH_SUFFIX_WITH_PREFIX, this.data).toString();
- } else {
- return URI.expand(STAGE_WITH_SUFFIX_WITHOUT_PREFIX, this.data).toString();
- }
- } else {
- if (this.includePrefix) {
- return URI.expand(STAGE_WITHOUT_SUFFIX_WITH_PREFIX, this.data).toString();
- } else {
- return URI.expand(STAGE_WITHOUT_SUFFIX_WITHOUT_PREFIX, this.data).toString();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement