-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Financial-Times/topic-url-helper
added helper for converting search strings to stream urls
- Loading branch information
Showing
3 changed files
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
module.exports = function(id, options) { | ||
// we treat id as a search string (what we're using as identifiers in v1) | ||
var parts = id.match(/^(.+)\:"([^"]+)"$/); | ||
|
||
if (parts) { | ||
parts = parts.slice(1, 3); | ||
if(['page'].indexOf(parts[0]) === -1) { | ||
return '/stream/' + parts.join('/'); | ||
} else { | ||
return '/' + parts.join('/'); | ||
} | ||
} | ||
|
||
// currently don't understand any other kinds of id e.g. capi2 id... to be fleshed out later | ||
// just return noop url for now, with something we can track | ||
return '#" data-track-invalid-url-' + id; | ||
}; |