Created
August 1, 2014 10:39
-
-
Save alexanderjeurissen/3cd2e8be561f3796dd20 to your computer and use it in GitHub Desktop.
A simple file name parser factory for angular projects.
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
angular.module('appointment') | |
.factory('FileNameParser', function () { | |
return { | |
parse: function (file) { | |
var extensionPattern = /\.[0-9a-z]+$/i; | |
var extension = extensionPattern.exec(file); | |
return { | |
file_name: file.replace(extension, ''), | |
file_type: extension[0].replace('.', '').toLowerCase() | |
}; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment